1

I have the following query:

SELECT `user_pwd` FROM (`td_user`) WHERE UPPER(user_name) = 'simmyp' AND  `status` = 'A'

In the db, user_name is stored as simmyp. The above query should not yield any result as SIMMYP != simmyp,but it displays records for simmyp. Why is it so? I am using utf8_general_ci.

Note: I would be using upper on both sides, but I would like to know how upper functions in the above case.

4

2 回答 2

2

您正在使用 utf8_general_ci - 您回答了自己的问题!“ci”代表不区分大小写。

那么你可以做的是:

SELECT `user_pwd` FROM (`td_user`) WHERE BINARY UPPER(user_name) = 'simmyp**' AND `status` = 'A'

或附加COLLATE utf8_bin到您的查询。

于 2013-06-04T21:01:06.137 回答
1

使用COLLATE运算符:)

SELECT `user_pwd` FROM (`td_user`)
WHERE `status` = 'A' AND UPPER(user_name) LIKE 'simmyp' COLLATE utf8_bin
于 2013-06-04T21:00:55.623 回答