Bug #14459 Field called "call" result in syntax or undefined error for sql query
Submitted: 29 Oct 2005 7:27 Modified: 29 Oct 2005 13:55
Reporter: Gianluca Corrias Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:Max 5.0.15 Linux (glibc-2.2/2.3) OS:Linux (Redhat Fedora1/7.2)
Assigned to: MySQL Verification Team CPU Architecture:Any

[29 Oct 2005 7:27] Gianluca Corrias
Description:
When in a table we have a field name "call", the result for a select query for this field result syntax or undefined error. No tested for different sql query.

How to repeat:
CREATE TABLE `test` (`call` varchar(20) default NULL,`call2` varchar(20) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1;

error: SELECT * FROM test WHERE call = 'xyz'
empty: SELECT * FROM test WHERE call2 = 'xyz'

Suggested fix:
Change field name.
[29 Oct 2005 13:55] MySQL Verification Team
Call is a reserved word and needs to be handled how described
in the Manual:

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.16-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE TABLE `test` (`call` varchar(20) default NULL,`call2` varchar(20) default
    -> NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Query OK, 0 rows affected (0.04 sec)

mysql> 
mysql> SELECT * FROM test WHERE call = 'xyz'
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax; <cut>

mysql> SELECT * FROM test WHERE `call` = 'xyz';
Empty set (0.00 sec)