So I have a system where admins can find a row by searching for a user-entered string and selecting in which column to search in.
Obviously, if I have an INT column id=0 in a few rows, they will all pop out in the results whatever the string as 'bob' will become 0 when cast to an INT, so
WHERE id = 'bob'
Will become
WHERE id = 0
So I got plenty of results that don't make sense.
I don't think there is a way to stop mysql from stopping implicit casting (besides it might break other things somewhere else in the site), but is there another solution to avoid this, knowing that the selected column to search in could either be a INT or a STRING? Or is there a way to detect incompatible types and return an empty result set without executing the query?