Reputation: 161
I have a table named user
like below:
id || email
---------------------------------
1 || someone@foo.bar
---------------------------------
2 || 1manwithblueshirt@bar.foo
---------------------------------
Why is this:
1manwithblueshirt@bar.foo
result of this search?
SELECT * FROM user WHERE email = 1
Upvotes: 3
Views: 922
Reputation: 1271003
Because MySQL decides to convert the email to an integer. The rules are to convert leading characters to a number, until the characters are not valid numbers.
Here is a simple example:
select (case when '1abc' = 1 then 'a' else 'b' end)
Upvotes: 5