Create a MySQL table with dashes

Problem

You want to create a MySQL table that contains spaces, but when you try you get the following error message:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-afterdash' at line 1

Solution

Use the backticks to create the table:

mysql> create database `table-afterdash`;
Query OK, 1 row affected (0.00 sec)