koralarts
koralarts

Reputation: 2112

INSERT INTO syntax error SQL

I am at a loss why I am getting this error. It might something I can't see in my syntax so any help would be greatly appreciated.

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 - 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 'require,require_explain) VALUES(410,DATE '2009-12-10',0,NULL,0,NULL,0,NULL,0,NUL' at line 1

Thanks.

Upvotes: 2

Views: 3372

Answers (3)

Michael Berkowski
Michael Berkowski

Reputation: 270767

REQUIREis a reserved MySQL keyword. You must enclose it in backquotes as:

`require`

Also, it's worth pointing out that MySQL escapes single quotes with a backslash, not two single-quotes like SQL Server and Access. This phrase may become problematic if the above is your exact SQL statement and that single quote has not been escaped:

Applican''t condition

Upvotes: 9

pkk
pkk

Reputation: 3701

I copy-pasted your query to MySQL Workbench, and it seems that you are using reserved require keyword as a name of a table column, to fix that:

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);

Upvotes: 0

Sebastiano Merlino
Sebastiano Merlino

Reputation: 1283

it's because "require" is a keyword backtick it.

Upvotes: 2

Related Questions