MySQL comparison operator, spaces

comparison-operators, mysql

Solution

The trailing spaces are omitted if the column is of type `char` or `varchar`; using `like 'usa '` resolves the issue

Problem

If the database row is like this: `country = 'usa'` and i query `"select * from data where country = 'usa '"` it also returns this row. So its not an exact match. Why MySQL does this? And in what other cases it will also return TRUE when its not really true?

Original source

Related problems