View Full Version : What's wrong with this statement?

07-13-2009, 10:18 AM
Ugh, sorry guys, I've been looking at it the past 5 mins trying everything but I can't seem to insert this record into the table.

INSERT INTO history (username,index) VALUES ('john','0')

Also tried

INSERT INTO history (username,index) VALUES ('john',0)

Tablename: history
username: Varchar of length 20
index: int of length 1

07-13-2009, 10:34 AM
index is a mysql keyword (http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html), so you can't use them in your queries as such.
You may use back-ticks like `index`, but it's better to avoid using such words for the name of your table/field.

07-13-2009, 10:47 AM
That worked, Thanks.