..............................mysql
MySQL 对字符串的后置空格是不敏感的,前置空格敏感sql
'dd'
,'dd '
,用select * from t_list where str='dd';
获取这两个结果(说明MySQL查询的时候,mysql有作righttrim的操做).net
' dd'
,'dd'
,用select * from t_list where str='dd';
获取这第二个结果(说明MySQL前置空格不敏感)code
'dd'
,'dd '
,用 select str,LENGTH(str) from t_list;
结果为2,3
,(说明查询结果中,空格的是包含在其中的。)blog
解决方法在字段前面添加 binary 关键字。'dd'
,'dd '
,select str,LENGTH('dd','dd ',) from t_list where str=Binary('dd');
获取结果 'dd',2
字符串