3 ms·
MySQL exhibits similar behavior if you're comparing numbers stored in a field with string-ish type (eg, varchar): mysql> select cast(123 as char(255)) > "2";
by Domenic_S 11y ago
MySQL exhibits similar behavior if you're comparing numbers stored in a field with string-ish type (eg, varchar):
mysql> select cast(123 as char(255)) > "2";
+------------------------------+
| cast(123 as char(255)) > "2" |
+------------------------------+
| 0 |
+------------------------------+
1 row in set (0.00 sec)
It can really bite you if you're filtering queries on "WHERE char_field > 10". I personally did not think a lot about datatypes after initial table creation... until I ran into this.