Android SQLite查询,其中列不为空且不为空 [英] Android SQLite query where column is not null and not empty
本文介绍了Android SQLite查询,其中列不为空且不为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法弄清楚.query调用的语法.我需要选择与特定列匹配的所有记录,而第二列(不同)的记录没有空值或空值
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
我最好的尝试:
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);
这将返回所有记录.如果我使用AND代替OR,它将返回与hospitalId匹配的记录,但会忽略NOT NULL或NOT"部分.
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.
有什么提示吗?我应该使用rawQuery调用吗?
Any tips? Should I use a rawQuery call?
推荐答案
我相信正确的语法是:
AND key IS NOT NULL AND key != ""
其中key
是您的列
这篇关于Android SQLite查询,其中列不为空且不为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文