Skip to content

Instantly share code, notes, and snippets.

@wh1t3p1g
Last active May 21, 2016 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wh1t3p1g/e854a01b316f07236d288adcb7a039c5 to your computer and use it in GitHub Desktop.
Save wh1t3p1g/e854a01b316f07236d288adcb7a039c5 to your computer and use it in GitHub Desktop.

where后面字符串最右忽略空格

首先插入2条语句
1.insert into user(username,password) values('admin','password')
2.insert into user(username,password) values('admin ','password')
查询一下
1.select username,password from user where username='admin'
2.select username,password from user where username='admin '
上面2条语句查询结果返回相同,将有空格的admin和无空格的admin都返回,这是mysql的一个bug,忽略字符串最右的空格

mysql强制转化

如果列id为整型,查询时id=0aaa会强制转化为0再进行查询

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment