I try to create a table in mysql using the following command:
CREATE TABLE keys (id INT(10), key VARCHAR(100));
But it always gives me an error similar to this:
Error 1064 (42000): There is an error in your SQL syntax; check the manual for your MySQL server version for "keys (id INT(10), key VARCHAR(100))" on line 1 Correct syntax to use nearby `
You should be very careful about naming tables and columns as you may face a lot of problems in the future.
I recommend finding names that are not MySQL reserved words.
If you still want to keep these names, you should surround them with backticks.
Please note that backticks must be used when using tables
So the table name
keys
and fieldkey
are reserved in the Mysql namespace. If you choose a different table name (e.g.keys_tbl
) and rename the second field tokey_id
, your code will work correctly.