Home > Database > Mysql Tutorial > body text

How to Resolve SQL Error 1064 When a Table Name Contains a Dash (-)?

Mary-Kate Olsen
Release: 2024-11-11 00:48:02
Original
1026 people have browsed it

How to Resolve SQL Error 1064 When a Table Name Contains a Dash (-)?

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
Copy after login

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`
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template