Adrian
Adrian

Reputation: 344

SQLiteException: near "''" in Android 2.1

I encountered and FC on my app when testing on Android 2.1 device. This happens in this query when I want to match PRODUCER_ID to an empty string.

managedQuery(CONTENT_URI, new String[]{Constants.NAME,
Constants.PRODUCER_ID}, Constants.PRODUCER_ID + " IS NULL OR " +
Constants.PRODUCER_ID + " IS ''", null, null);

Exception:

android.database.sqlite.SQLiteException: near "''": syntax error: ,
while compiling: SELECT name, producer_id FROM beverages WHERE
producer_id IS NULL OR producer_id IS ''

What am I doing wrong?

Upvotes: 0

Views: 119

Answers (1)

paulsm4
paulsm4

Reputation: 121669

Substitute "=" or "like" for "IS".

"is null" or "is in (...)", "is between","is not null", etc etc are all valid. "is ''" isn't.

Upvotes: 1

Related Questions