sql

mysql比较字符串忽略结尾的空白

Posted by rk700 on December 28, 2014

今天学习到一个知识点,在查询时如果比较字符串,会忽略结尾的连续空白,起始的空白不会忽略。于是:

select * from users where user='admin ';

会把user='admin'的记录也选出。

这里有比较详细的例子,而且mysql的官方文档也说了:

In particular, trailing spaces are significant, which is not true for CHAR or VARCHAR comparisons performed with the = operator