INSERT INTO语法错误SQL

时间:2011-08-16 20:21:18

标签: mysql sql

我不知道为什么我会收到此错误。这可能是我在语法中看不到的,所以任何帮助都会非常感激。

STATEMENT

INSERT INTO pwd_review (id, request_date, being_reviewed, review_explain, 
                        attached_docs, doc_explain, age_met, age_explain, 
                        years_met, years_explain, severity, severity_explain, 
                        restriction, restriction_explain, require, require_explain) 
VALUES(410, DATE '2009-12-10', 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0,
       'Dr M Beaulieu has provided further information indicating that applicant is severly ill and disabled. Applican''t condition is confirmed as rectal adenocarcinoma, she has endured dhemo and readiation therapy and is under care of the Oncology Team, surgeon and GP.', 0,
       'Information from Dr states that applicant is unable to sit, has great difficulty walking and requires ongoing support from the Community Support Services',
       0, NULL);

ERROR

  

1064 - 您的SQL语法出错;查看手册

     

对应于您的MySQL服务器版本以获得正确的语法   在'require,require_explain)附近使用VALUES(410,DATE   '2009-12-10',0,NULL,0,NULL,0,NULL,0,NUL'在第1行

感谢。

3 个答案:

答案 0 :(得分:8)

REQUIREreserved MySQL keyword。您必须将其括在反引号中:

`require`

此外,值得指出的是,MySQL使用反斜杠转义单引号,而不是SQL Server和Access等两个单引号。如果以上是您的确切SQL语句并且单引号未被转义,则此短语可能会成为问题:

Applican''t condition

答案 1 :(得分:2)

这是因为“require”是一个关键字反引号。

答案 2 :(得分:0)

我将您的查询复制粘贴到MySQL Workbench,似乎您使用保留的require关键字作为表列的名称来修复它:

INSERT INTO pwd_review (id, request_date, being_reviewed, review_explain, 
                        attached_docs, doc_explain, age_met, age_explain, 
                        years_met, years_explain, severity, severity_explain, 
                        restriction, restriction_explain, `require`, require_explain) 
VALUES(410, DATE '2009-12-10', 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0,
       'Dr M Beaulieu has provided further information indicating that applicant is severly ill and disabled. Applican''t condition is confirmed as rectal adenocarcinoma, she has endured dhemo and readiation therapy and is under care of the Oncology Team, surgeon and GP.', 0,
       'Information from Dr states that applicant is unable to sit, has great difficulty walking and requires ongoing support from the Community Support Services',
       0, NULL);