Android SQLite LIKE escape wildcard

In Android Jellybean 4.1, can I escape the LIKE wildcard character and still use the index?

Using:

where field like 'xyz\_abc' 

Unlike:

 where field like 'xyz_abc' 

Does screen masks hold on Android? And will it use an index if the wildcard is escaped?

I am currently doing the following:

 where field like 'xyz_abc' and lower(field) = lower('xyz_abc') 

Which is terribly inefficient due to the wildcard.

thanks

+6
source share
1 answer

You need to use the ESCAPE clause:

 where field like 'xyz\_abc' escape '\' 

See the LIKE and GLOB statements section in the SQLite documentation.

+16
source

All Articles