3

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
CL.
  • 173,858
  • 17
  • 217
  • 259
lucignolo
  • 223
  • 2
  • 12

3 Answers3

4

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*'
CL.
  • 173,858
  • 17
  • 217
  • 259
-2

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

Community
  • 1
  • 1
Caffeinated
  • 11,982
  • 40
  • 122
  • 216
-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%'
Community
  • 1
  • 1
Martin
  • 4,711
  • 4
  • 29
  • 37