Bug #65316 | SELECT MAX with integer as string comparison returns the wrong result | ||
---|---|---|---|
Submitted: | 15 May 2012 7:02 | Modified: | 15 May 2012 7:52 |
Reporter: | Maarten Kossen | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.5.22 | OS: | Linux (5.5.22-0ubuntu1) |
Assigned to: | CPU Architecture: | Any |
[15 May 2012 7:02]
Maarten Kossen
[15 May 2012 7:52]
Valeriy Kravchuk
Why do you think this is a bug? When you compare values of VARCHAR column with a string, '100', then values are compared with strings, and '99' is the "greatest" of '10', '100' and '99', just because it starts with '9'. When you compare with numeric literal, 100, then values are compared as numbers, strings are converted to numbers before comparison and, surely, '100' is the greatest. All this is documented, see http://dev.mysql.com/doc/refman/5.5/en/type-conversion.html for details.