请修改MySQL语法中的调试错误

时间:2012-06-19 02:12:09

标签: php mysql sql syntax

任何想法我做错了???

INSERT INTO LondonFixes ('id', 'Metal', 'AmPm', 'GBP', 'USD', 'EUR', 'Updated')VALUES(NULL, 'Gold', 'AM', '1055.91', '1646.00', '1272.03', '2012-06-19')

给出以下错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''id', 'Metal', 'AmPm', 'GBP', 'USD', 'EUR', 'Updated')VALUES(NULL, 'Gold', 'AM',' at line 1

2 个答案:

答案 0 :(得分:2)

 INSERT INTO LondonFixes (id, Meta, AmPm, GBP, USD, EUR, Updated)
 VALUES(NULL, 'Gold', 'AM', '1055.91', '1646.00', '1272.03', '2012-06-19')

答案 1 :(得分:1)

在MySQL中,如果要转义列名,请不要使用single quote,而是使用backtick

INSERT INTO LondonFixes (`id`, `Metal`, `AmPm`, `GBP`, `USD`, `EUR`, `Updated`)
VALUES(NULL, 'Gold', 'AM', '1055.91', '1646.00', '1272.03', '2012-06-19')