英文:
WHERE clause with '=' operator doesn't return exact match
问题
我尝试了一个带有WHERE
子句的SELECT
,用于搜索一个错误的字符串,但结果显示了正确的字符串,进一步的测试显示WHERE
子句中的=
运算符不能返回精确匹配。
我尝试搜索解决方案,但在Google或Stack Overflow中找不到任何解决方法。
简化示例
SELECT *
FROM LoginCredential
WHERE UserID = 'ad'
英文:
I tried a SELECT
with a WHERE
clause searching for a wrong string but the result showed the right string, which further testing showed the WHERE
clause with the =
operator doesn't return the exact match.
I have tried to search for solutions but can't find any through Google or Stack Overflow.
Simplified example
SELECT *
FROM LoginCredential
WHERE UserID = 'ad'
答案1
得分: 0
你的问题似乎已经在这里被提出并有答案:https://stackoverflow.com/questions/1831105/how-to-do-a-case-sensitive-search-in-where-clause-im-using-sql-server
供您参考:
SELECT *
FROM LoginCredential
WHERE UserID = 'ad' COLLATE SQL_Latin1_General_CP1_CS_AS
英文:
You question appears to have already been asked and has an answer here https://stackoverflow.com/questions/1831105/how-to-do-a-case-sensitive-search-in-where-clause-im-using-sql-server
For your easy reference:
SELECT *
From LoginCredential
WHERE UserID = 'ad' COLLATE SQL_Latin1_General_CP1_CS_AS
答案2
得分: -3
如果您正在使用MySQL,看起来您创建了一个大小写不敏感的数据库,比如utf8mb4_general_ci,ci表示大小写不敏感,请更改为utf8mb4_general_cs(大小写敏感)。
英文:
If you are using MySQL, looks like you create a DB in case insensitive, like utf8mb4_general_ci, ci means case insensitive, change to utf8mb4_general_cs (case sensitive)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论