I cannot figure out the syntax for the .query call. I need to select all records that match a certain column that do not have a null or empty value for a second (different) column
我无法弄清楚.query调用的语法。我需要选择与某个列匹配的所有记录,这些列对于第二个(不同的)列没有空值或空值
my best attempt:
我最好的尝试:
Cursor cursor = mDatabase.query(DatabaseOpenHelper.TABLE_ROOMS, mAllColumns,
DatabaseOpenHelper.KEY_ROOM_HOSPITAL_ID
+ " =? AND " + DatabaseOpenHelper.KEY_ISO + " IS NOT NULL OR NOT ?",
new String[]{String.valueOf(hospitalId), ""}, null, null, null);
This is returning ALL records. If I use AND in place of OR, it returns records matching hospitalId, but ignores the NOT NULL OR NOT "" part.
这将返回所有记录。如果我使用AND代替OR,它返回与hospitalId匹配的记录,但忽略NOT NULL或NOT“”部分。
Any tips? Should I use a rawQuery call? Thank you.
有小费吗?我应该使用rawQuery调用吗?谢谢。
1 个解决方案
#1
34
I believe the correct syntax would be:
我相信正确的语法是:
AND key IS NOT NULL AND key != ""
where key
is your column
其中key是你的专栏
#1
34
I believe the correct syntax would be:
我相信正确的语法是:
AND key IS NOT NULL AND key != ""
where key
is your column
其中key是你的专栏