Ankit Chhabra
Ankit Chhabra

Reputation: 73

how to use like operation in sqlite android

I am working on a database with sqlite in an android app I want to get some data using a like clause

cursor = db.rawQuery("select * from INTERESTS contactid LIKE '%=?%'", new String[]{id + ""});

Upvotes: 1

Views: 283

Answers (1)

laalto
laalto

Reputation: 152797

Assuming you really want to use the LIKE operator: ? variables don't go in quoted literals. You can use || to concatenate variables and literals:

contactid LIKE `%` || ? || '%'

(Left out the = in the LIKE pattern as it seemed out of place.)

Assuming you actually want an exact match and not LIKE:

contactid = ?

Upvotes: 3

Related Questions