user1813706
user1813706

Reputation: 101

Issue in sqlite with "like" in android

In sqlite don't have the operator [ ] for like.

For example,

select * from user where name LIKE '%[abch]%';

this work is all the others sqlserver,oracle but not in sqlite.

Someone know an alternative in sqlite for this?

I am working with android.

I think I can't use regexp because I am using android.

Upvotes: 4

Views: 571

Answers (1)

smith324
smith324

Reputation: 13060

sqlite only supports a small subset of regular sql. http://www.sqlite.org/lang_expr.html

See Query Android's SQLiteDatabase using Regex about using regex on Android.

Short answer, dont bother. You can use like for the basics and anything else you really shouldn't be using regex for.

You can always do this select * from user where name LIKE '%a%' or name LIKE '%b%' or name LIKE '%c%' or name LIKE '%h%' ;

Upvotes: 1

Related Questions