问题
Why isn't my query case sensitive?
Select * from MyTable where name like '%Ann%'
shows record 1 correctly:
Record1= John, Ann, Jack
but shows also record 2:
Record2: Jack, Susanne, Jim
回答1:
You could execute PRAGMA case_sensitive_like = on, but this would affect all LIKEs used in your program, and disable any index optimizations for prefix searches.
A better idea would be to replace LIKE with GLOB:
SELECT * FROM MyTable WHERE Name GLOB '*Ann*'
回答2:
[Copied from rbedger's answer:]
You can use the UPPER keyword on your case insensitive field then upper-case your like statement
SELECT * FROM mytable
WHERE caseSensitiveField like 'test%'
AND UPPER(caseInsensitiveField) like 'G2%'
回答3:
the SQL LIKE is case-insensitive(thnks to CL ) So, on some SQL implementations you can do case Sensitive SQL query Searches
check this too: Case insensitive searching in Oracle
来源:https://stackoverflow.com/questions/22310981/query-with-like-but-case-sensitive