Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在表中有 2 行,
field ----- A A //and space
也就是说A,如果A有正确的空格,列类型是VARCHAR(3),
A
VARCHAR(3)
这个查询
SELECT field FROM `table` WHERE field = 'A'
返回两行,
问题:为什么返回行A也有正确的空间?
MySQL 中的字符相等比较是在不考虑尾随空格的情况下执行的。如果要考虑尾随空格,可以使用LIKE运算符。
LIKE
读这个。
http://dev.mysql.com/doc/refman/5.5/en/char.html