select "张三 " = "张三" # 输出1
select " 张三 " = "张三" # 输出0
select " 张三" = "张三" # 输出0
根据上面的SQL可以看到,如果MySQL的比较条件参数是字符串,那么MySQL会自动省略字符串中的后空格。
参考文档:
- https://deepinout.com/sql/sql-questions/146_sql_sql_string_comparison_ignores_space.html
- https://www.cnblogs.com/xjnotxj/p/9019866.html
- https://dev.mysql.com/doc/refman/5.7/en/char.html