I think the reason is that MySQL is BRAIN DEAD!!!
No other DB would do this.
But look here:
Code:
mysql> select n, n=0 from foo;
+----------------------------+------+
| n | n=0 |
+----------------------------+------+
| adam | 1 |
| bob | 1 |
| xyz | 1 |
| 11111111111111111111111111 | 0 |
| 000000000000000000 | 1 |
| ! | 1 |
| @ | 1 |
| # | 1 |
| a | 1 |
| A | 1 |
| 0 | 1 |
| 1 | 0 |
| 10 | 0 |
+----------------------------+------+
13 rows in set (0.00 sec)
And then also look here:
Code:
mysql> select n,n=0,n=1,n=2,n=3,n=4 from foo where n in ('adam','0','1');
+------+------+------+------+------+------+
| n | n=0 | n=1 | n=2 | n=3 | n=4 |
+------+------+------+------+------+------+
| adam | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 0 |
+------+------+------+------+------+------+
So clearly the rule is this: "If the value is convertible to a number, then the numeric value is tested. But all values not convertible to a number are equal to numeric zero but not to any other numeric value."
What an UTTERLY perverted definition!!
I would LOVE to hear somebody on the MySQL team justify this definition.