在一个columm SQLite的查询多个值 [英] Sqlite Query for multiple values in one columm

查看:286
本文介绍了在一个columm SQLite的查询多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做查询表中字段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);

这篇关于在一个columm SQLite的查询多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆