从SQLite数据库检索一组行 [英] Retrieving a set of rows from the sqlite database

查看:171
本文介绍了从SQLite数据库检索一组行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT * FROM <TableName> WHERE <attribute(id)> IN <ArrayList type>

但theres一个错误

but theres an error

04-24 21:18:41.748:
  ERROR /错误(29495):
  android.database.sqlite.SQLiteException:
  没有这样的表:1:,在编译:
  SELECT * FROM WHERE主ID [1]

04-24 21:18:41.748: ERROR/Error(29495): android.database.sqlite.SQLiteException: no such table: 1: , while compiling: SELECT * FROM Main WHERE id IN [1]

基本上,我要选择与属性(ID),这是一个ArrayList present的行...
但ArrayList的格式是不一样的一个REQD对于这种类型的查询(我猜)
我想这就是原因,其无法正常干活

basically i want to select those rows with Attribute(id) which are present in an ArrayList... but the format of the ArrayList is not the same as the one reqd for this type of query(i guess) and i think this is the reason, its not workin correctly

如果我查询它:

SELECT * FROM <TableName> WHERE <attribute(id)> IN <Integer>

它显示我正确的结果......但OBV只选择了特定的ID的行...

it shows me the correct result... but obv it only selects that particular id's row...

请注意:ArrayList中被替换为整数...(这是该数据类型我属性(ID))

note: ArrayList is replaced with Integer... (which is the data-type of my attribute(id))

在此先感谢:)

推荐答案

有没有这样的事情上述&lt; ArrayList的类型方式&gt;

There is no such thing as IN <ArrayList type>.

您需要使用JAVA code给自己计算枚举字符串。

You need to compute the enumerating string yourself by using JAVA code.

SELECT * FROM <TableName> WHERE _id IN ('1','2','3','4','5')

另外请注意,在Android的主键建议是 _id 带下划线。

这篇关于从SQLite数据库检索一组行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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