我想知道是否可以(应该)在 SQLite 中同时(一次几个)查询多个表。基本上我有几个表具有完全相同的列,但它们中的数据只是由它所在的表组织。我需要能够用来SELECT
从表中获取数据(我听说UNION
可以帮助),这符合条件,然后按数据所在的表对数据进行分组。
换句话说,这样的事情可能吗?
SELECT * FROM table1,table2,table3,table4,table5,table6 WHERE day=15 GROUP BY {table}
我宁愿不必单独查询表,因为那样我就会有一堆Cursors
我必须手动完成的事情,而当我只有一个时这会很困难SimpleCursorAdapter
?除非一个SimpleCursorAdapter
可以有几个Cursor
s?
谢谢。
编辑:我的表的结构:
Main Table - contains references to subtables in a column "tbls"
and meta-information about the data stored in the subtables
Subtable - contains reference to subsubtables in a column "tbls"
and meta-information about the data stored in the
subsubtables
Subsubtable - contains the actual entries
基本上,这些表只是使组织分层数据结构变得更容易。我想我可以保留actual entries
子表而不是子表,但添加一个前缀,并为元信息创建一个单独的表。如果我需要删除此数据集中的一个级别,似乎删除/更新结构会更加困难。