OK, this is really weird, and I am not sure whether it's a MySQL bug or a feature, but I don't like it.
Let's say I have a table that has a CHAR(60) field ('Name') and INT(11) field ('id').
The query I run is
SELECT * FROM test WHERE id = "dfgfg"
I think that it should either return an empty set (because obviously "dfgfg" is not an INT and can't possibly be a valid value), or, as a worst case scenario, break. Instead, it returns all rows where ID is 0.
The same happens if I look for rows where id="" (empty string).
Is there a way to make MySQL return only the rows that are REALLY equal to WHERE values?
I know that application should check all values that are passed to MySQL from the user... But if returning everything that equals to 0 whenever the type of a search value doesn't match the field type is expected behavior in MySQL, it's just scary.