Home >Database >Mysql Tutorial >Can MySQL Table Columns Be Named with Numbers?
Can Numbers Be Used as MySQL Table Column Names?
Using a number as a MySQL table column name can lead to unexpected errors. As stated in the documentation, identifiers (including column names) may begin with a digit, but they cannot consist solely of digits unless they are quoted.
In the provided example, the column names are numbers (e.g., 25, 50, 100), which is why the update operation with single quotes (e.g., UPDATE table SET '25'='100' WHERE id = '1') results in a syntax error.
To resolve the issue, column names containing numbers must be enclosed in backticks, as demonstrated in the corrected update statement:
UPDATE table SET `25`='100' WHERE>
By using backticks, the identifier "25" is recognized as a column name and not simply a value, resolving the syntax error.
The above is the detailed content of Can MySQL Table Columns Be Named with Numbers?. For more information, please follow other related articles on the PHP Chinese website!