我需要找出以下 SQL 失败的原因:
INSERT INTO users ('c_id', 'c_email', 'c_fname', 'csname', 'c_mobile', 'c_add_1', 'c_add_2', 'c_city', 'c_county', 'c_postcode', 'c_comments') VALUES ('null','josh','hh', 'hh', 'hhhh', 'hh', 'hhh', 'hhh', 'hhhh', 'hh', 'hhh')
我试过了,c_id 不为空。
我收到以下消息:
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 ''c_id', 'c_email', 'c_fname', 'csname', 'c_mobile', 'c_add_1', 'c_add_2', 'c_cit' at line 1
最佳答案
在 SQL 中,单引号 ('
) 表示字符串文字,而不是对象名称。您应该将它们从列列表中删除:
INSERT INTO users (c_id, c_email, c_fname, csname, c_mobile, c_add_1, c_add_2, c_city, c_county, c_postcode, c_comments)
VALUES ('null','josh','hh', 'hh', 'hhhh', 'hh', 'hhh', 'hhh', 'hhhh', 'hh', 'hhh')
关于mysql - SQL 查询错误 - 检查与您的 MySQL 服务器版本对应的手册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30040064/