Bug #11319 SELECT without quoting returns unexpected lines on VARCHARs
Submitted: 14 Jun 2005 14:38 Modified: 17 Jun 2005 19:50
Reporter: Oliver Kuhl Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.24 OS:Linux (Debian Linux (sarge))
Assigned to: CPU Architecture:Any

[14 Jun 2005 14:38] Oliver Kuhl
Description:
A SELECT-statement returns unexpected lines when querying for a VARCHAR-field without quotes. Watch the example to understand...

Oliver.

How to repeat:
CREATE TABLE `seltest` (`t` VARCHAR( 5 ) NOT NULL);
INSERT INTO `seltest` ( `t` ) VALUES ('1234');
INSERT INTO `seltest` ( `t` ) VALUES ('1234x');
SELECT * FROM `seltest`WHERE t =1234;

+-------+
| t     |
+-------+
| 1234  |
| 1234x |
+-------+
2 rows in set (0.00 sec)
[17 Jun 2005 19:50] MySQL Verification Team
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

If one of the arguments is string and the other is number they are compared as floating-point numbers.

http://dev.mysql.com/doc/mysql/en/comparison-operators.html