Kyle0032
Kyle0032

Reputation: 11

SQL Syntax Error: Can anyone see an issue here?

I am getting a syntax error with this SQL statement. I am a little stumped as everything seems to be ok to me...

INSERT INTO vehicle (vin,plate,plateprov,condition,year,makecode,make,model,bstyle,mileage,colour,twotone,paintstage,impact1) 
VALUES ('3VWSF31K36M617923','ARDM093','ON','GO','06','47','Volkswagen','Jetta','4D Sed','132123','BURGUNDY','0','0','07')

Here is my table structure:

id  int(11) 
vin varchar(17)
plate   varchar(10)
plateprov   varchar(2)
condition   varchar(2)
year    int(11)
makecode    varchar(12)
make    varchar(20)
model   varchar(50)
bstyle  varchar(20)
engine  varchar(20)
mileage int(7)
colour  varchar(20)
twotone int(11)
paintstage  int(11)
paintcode1  varchar(15)
paintcode2  varchar(15)
paintcode3  varchar(15)
impact1 varchar(2)
impact2 varchar(30)

ERROR Message I get:

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 'condition,year,makecode,make,model,bstyle,mileage,colour,twotone,paintstage,impa' at line 1

Any help is much appreciated.. Kyle

Upvotes: 1

Views: 27

Answers (2)

Daniel Waghorn
Daniel Waghorn

Reputation: 2985

Try it with back ticks on your column names.

INSERT INTO vehicle (`vin`,`plate`,`plateprov`,`condition`,`year`,`makecode`,`make`,`model`,`bstyle`,`mileage`,`colour`,`twotone`,`paintstage`,`impact1`) 
VALUES ('3VWSF31K36M617923','ARDM093','ON','GO','06','47','Volkswagen','Jetta','4D Sed','132123','BURGUNDY','0','0','07')

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1269463

CONDITION is a reserved word. You should find another name for the identifier, or include it in backticks.

The list of reserved words is readily available (see here).

The use of CONDITION is rather arcane, so it is not an obvious reserved word. Here is the documentation for it. However, this type of error almost always means an issue with a reserved word.

Upvotes: 1

Related Questions