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.
  • 165,803
  • 15
  • 203
  • 239
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.
  • 165,803
  • 15
  • 203
  • 239
-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,134
  • 39
  • 115
  • 205
-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,543
  • 4
  • 25
  • 32