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
  • 955
  • 1
  • 9
  • 28
Sunita
  • 1,209
  • 11
  • 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
  • 144,748
  • 64
  • 275
  • 293
  • This is really useful.It worked perfectly fine for me and simplest way to achieve the goal. – Sunita Jan 11 '14 at 18:31
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.
  • 165,803
  • 15
  • 203
  • 239