Page 1 of 1

Bad Syntax

Posted: Thu Mar 19, 2015 9:49 pm
by DavJans
I've been looking at this for an hour now and I cant see it, please help.
INSERT INTO camber (job, pcmk, size, length, rcamber, mcamber, stops, blocks, left, middle, right, date) VALUES ('TEST','TEST','21 X 50','37|SQ 10|DQ','0|DQ 1/2','0|DQ 1/2','B','2','1|DQ 1/2','1|DQ 9/16','1|DQ 1/2', NOW())


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 'left, middle, right, date) VALUES ('TEST','TEST','21 X 50','37|SQ 10|DQ','0|DQ 1' at line 1

Re: Bad Syntax

Posted: Thu Mar 19, 2015 11:13 pm
by Klaus
Hi DavJans,

aren't "left, middle, right, date" not some kind of "reserved words" in SQL?


Best

Klaus

Re: Bad Syntax

Posted: Thu Mar 19, 2015 11:26 pm
by DavJans
Thank you klaus,

I just came back here to post that i figured it out, it didnt complain about middle, it let me use date, but not left or right.

I figured it out by typing my query into mysql workbench and it highlighted left and right and date, but still let me use date.

however, you can create a table with those in it.... at least now i know.

Re: Bad Syntax

Posted: Thu Mar 19, 2015 11:37 pm
by SparkOut
If you enclose the "reserved" column names in "backticks" ( the left-leaning "single quote" usually found on the top-left side of the keyboard near the tab and the digit 1 depending on your keyboard layout, you might find SQL errors will be sidestepped.