Case-sensitive SQL differentiate between upper and lower case

扶醉桌前 提交于 2019-12-07 16:50:12

问题


I'm trying to have a request with a case sensitive result.

For example in my database I have

ABCdef
abcDEF
abcdef

The request is

SELECT * FROM table WHERE col = 'abcdef'

but I have my 3 rows as result and I just want abcdef

I try to find a solution with

SELECT * 
FROM table 
WHERE col COLLATE Latin1_General_CS_AS = 'abcdef' COLLATE Latin1_General_CS_AS 

but I have this error:

Unknown collation: 'Latin1_General_CS_AS'{"success":false,"error":"#1273 - Unknown collation: 'Latin1_General_CS_AS'"}

Thanks


回答1:


Thanks for your help I find the solution it was not latin1 ut utf8

COLLATE utf8_bin



回答2:


Latin1_General_CS_AS is a SQL Server collation.

For MySQL, try latin1_general_cs:

WHERE col = 'abcdef' COLLATE latin1_general_cs 


来源:https://stackoverflow.com/questions/16262963/case-sensitive-sql-differentiate-between-upper-and-lower-case

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!