This is the result of some implicit conversion in order to do a numerical comparison:
SELECT * FROM cards WHERE number='123'
This will only match against text fields that are literally "123"
and will miss on " 123"
and "123\r"
if you have those. For some reason, "123 "
and "123"
are considered "equivalent" presumably do to trailing space removal on both sides.
When doing your import, don't forget LINES TERMINATED BY '\r\n'
. If you're ever confused about what's in a field, including hidden characters, try:
SELECT HEX(number) FROM cards
This will show the hex-dumped output of each string. Things like 20
indicate space, just as %20
in a URL is a space.
You can also fix this by:
UPDATE cards SET number=REPLACE(number, '\r', '')