与selectionArgs两个空的SQLite查询 [英] SQLite query with selectionArgs null
本文介绍了与selectionArgs两个空的SQLite查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用String selectionArgs两个查询()语句。我想设置selectionArgs两个中的一个为空,因为我还没有使用它。前
光标CUR = sqlite_obj.query(表名,空,UID =和年龄与GT;????和客房= AND阿德雷=,新的String [] {31,,3 ,},NULL,NULL,NULL,NULL);
I use the String selectionArgs in query() statement. I want set one of selectionArgs to null, as I have not use its. Ex "
Cursor cur = sqlite_obj.query(TableName, null, "UID = ? AND Age > ? AND Room = ? AND Adre = ?", new String[] { "31", "" ,"3", ""}, null, null, null, null);
但我不使用第二selectionArgs两个和4ND selectionArgs两个或3ND可空。我该怎么办?
But I do not use 2nd and 4nd of selectionArgs or 3nd of selectionArgs can null. How I do ?
在此先感谢。
推荐答案
也许你需要使用两个querys。
Maybe you need to use two querys.
String where="";
String []params=null;
if(hasAge){
where="UID = ? AND Age > ?";
params=new String[] { String.valueOf(iud), String.valueOf(age) };
}else{
where="UID = ? ";
params=new String[] { String.valueOf(iud) };
}
Cursor cur = sqlite_obj.query(TableName, null, where, params, null, null, null, null);
这篇关于与selectionArgs两个空的SQLite查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文