Home  >  Article  >  Backend Development  >  mysql数据库查询语句解决办法

mysql数据库查询语句解决办法

WBOY
WBOYOriginal
2016-06-13 13:51:51872browse

mysql数据库查询语句
binary   A.username   LIKE   '%$keyword% ',请问这与不用binary的语句A.username   LIKE   '%$keyword% '有什么区别??
那个更好啊,请大侠帮我解释下

------解决方案--------------------
binary区分大小写
------解决方案--------------------
1、区分大小写
2、这样可以对中文进行LIKE操作。
------解决方案--------------------
like binary 更好 可以更精确的匹配 如果这个$kword 你赋个值 让他等于‘a’你就看到区别了
------解决方案--------------------

不仅是大小写的问题,
对一些collation, 有些字符或组合有特别含义,
如latin1_german2_ci中, Ä = AE
就是说你 where x like 'AE% ' 会把 'Äxxx ' 也找出来

用了binary就完全按照字符二进制值查找了,相当于没有字符集

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn