2

I am using glob operator with "?" wildcharater.The problem is - it is case sensitive.

So suppose I want to search for "Hola", then below query does not work.

select * from tableName where columnName glob 'ho?a';

I can use LOWER or UPPER keywords with columnName , but then it also it fails for the text which is a combination of lower and upper case letters.

Please give your inputs.

Samira Khorshidi
  • 963
  • 1
  • 9
  • 29
Sunita
  • 1,219
  • 12
  • 16
  • See [this probably duplicate] [question](http://stackoverflow.com/questions/973541/how-to-set-sqlite3-to-be-case-insensitive-when-string-comparing) - the general tool SQL has to deal with this is COLLATIONS; also, while same-casing both values ought to "work", SQLite won't be able to use indices AFAIK – user2864740 Jan 09 '14 at 06:31

2 Answers2

3

GLOB is case sensitive by design.

If you want case insensitive matching, use LIKE, with _ matching a single character:

select * from tableName where columnName like 'ho_a';
laalto
  • 150,114
  • 66
  • 286
  • 303
3

GLOB supports character classes:

SELECT * FROM tableName WHERE columnName GLOB '[hH][oO]?[aA]';

However, using LIKE would be easier, unless you actually need to use character classes in some other part of the pattern.

CL.
  • 173,858
  • 17
  • 217
  • 259