How can I create a column name that is an age range ’18-49′ in MYSQL

I just need to create a table with column names that are age ranges, but when I add a – sign it returns an error. What I need to have is like this:

+------------+
| ages_0-4   |
+------------+
| Tim        |
+------------+
| Bobby      |
+------------+
| Jim        |
+------------+

The column name has an age range ‘0-4’ it returns error when I try this.

The query I’m trying to run:

create table tested (0-4_tested varchar(255));

I wasn’t able to find anything on the internet so I’ve come here.

Answer

You can skip such character using “`”

create table tested (`0-4_tested` varchar(255));

Leave a Reply

Your email address will not be published. Required fields are marked *