Bug #5921 INSERT explicit column definition bug when column titled 'when'
Submitted: 6 Oct 2004 13:06 Modified: 6 Oct 2004 14:02
Reporter: Cliff Lassnig Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S3 (Non-critical)
Version:3.23.54 - 4.0.15-standard OS:Linux (Linux Redhat)
Assigned to: CPU Architecture:Any

[6 Oct 2004 13:06] Cliff Lassnig
Description:
When you explicit define column names in an insert statement - if one of your column names happens to be called "when" - it fails.

3.23.54

mysql> insert into test (NAME,WHEN,TEL) values ('test','2004-05-01','232323');
ERROR 1064: You have an error in your SQL syntax near 'WHEN,TEL) values ('test','2004-05-01','232323')' at line 1

4.0.15-standard

mysql> insert into test (NAME,TEL,when) values ('test','test','3333');
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 'when) values ('test','test','3333')' at line 1

Am I going mad or what?

How to repeat:
Just create a table, call one of your fields, "when" (datatype doesn't matter) - then try to insert a record explicitly defining column names.

insert into test (NAME,TEL,when) values ('test','test','3333');

Suggested fix:
Don't call any column names, WHEN!
[6 Oct 2004 14:02] MySQL Verification Team
Hi,

Thank you for the report, but this isn't really a bug. Please, read carefully MySQL manual that available at:
http://dev.mysql.com/doc/mysql/en/index.html