Resolving SQL Error 1064 When Table Name Includes a Dash (-)
An error may occur while attempting to backup a MySQL database due to a table name containing a dash (-). This error typically appears as:
Error Number: 1064 ... SELECT * FROM temp_01-01-000001
To resolve this issue and allow table names with dashes, it is necessary to enclose the table name in backticks (`). This informs MySQL to treat the table name as a string rather than a reserved word.
For example, the following corrected query should resolve the error:
SELECT * FROM `temp_01-01-000001`
By enclosing the table name in backticks, MySQL will recognize it as a valid table name and correctly execute the query. This technique allows you to use hyphens or dashes in table names without encountering the error.
The above is the detailed content of How to Resolve SQL Error 1064 When a Table Name Contains a Dash (-)?. For more information, please follow other related articles on the PHP Chinese website!