I created a database without defining the char set so it defaulted to Latin. Now I need to make a case sensitive search so I used the command:
$sql = "SELECT * FROM Users WHERE username = '$value' COLLATE SQL_Latin1_General_CP1_CS_AS";
The problem is that it returns no matches. In my web page I have the <meta charset="utf-8">
in the head
of the page, so I wonder if the charset encoding could be the problem. If I make a search without the COLLATE SQL_Latin1_General_CP1_CS_AS
it works but it is case insensitive.
What could be the problem? Should I convert the database to always use utf-8?
尝试二进制运算符:
$sql = "SELECT * FROM Users WHERE BINARY username = '$_POST[userName]'";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.