在一个columm SQLite的查询多个值多个、columm、SQLite

2023-09-05 08:51:01 作者:不是God你不懂!

我想做查询表中字段ID一些的山谷像1,5,4,11这将根据选择来自于previous屏幕。

i wanted to do query in table for field id with some vales like 1,5,4,11 which will come from previous screen according to selection.

cursor = database.query(tablename,
                    new String[] { "TopName" }, "id =?", new String[]{"2,3"}, null, null, null);

当我不喜欢这样我得到光标数0,用新的String [] {2}我得到的价值,我想与价值观所有ID字符串数组喜欢或具有在该列中的值。

when i do like this i am getting cursor count 0,with new String[]{"2"} i am getting value i want for all ids with values in string array like OR which have value in that column.

推荐答案

您可以使用运营商这样的,

You can use the IN operator like this,

cursor = database.query(tablename, new String[] {"TopName"}, "id IN(?,?)", 
                                        new String[]{"2","3"}, null, null, null);
 
精彩推荐
图片推荐