Using Dashes in MySQL Table Names
If you encounter an error like "Error Number: 1064... check the manual... near '-01-000001' at line 1," while backing up your database, it's likely due to a dash (-) in the table name. MySQL doesn't allow dashes in table names without specific handling.
To resolve this issue:
SELECT * FROM `temp_01-01-000001`
By enclosing the table name in backticks, the dash symbol loses its special meaning, and MySQL treats the table name as a string.
SELECT * FROM "temp_01-01-000001"
Either of these methods will allow you to query the table with a dash in its name. Remember to include the backticks or double quotes whenever you reference the table, otherwise you may still encounter errors.
The above is the detailed content of Why does MySQL give an error when using dashes in table names?. For more information, please follow other related articles on the PHP Chinese website!