简体   繁体   English

一对多SQLite关系查询

[英]one-to-many SQLite relationship query

have an sqlite database that holds many cities, each city has a month and each month has 30 days. 有一个包含许多城市的sqlite数据库,每个城市有一个月,每个月有30天。 i created this database using CoreData when i was developing iOS apps on Xcode. 在Xcode上开发iOS应用时,我使用CoreData创建了此数据库。 now i want to retrieve the days that belongs to a specific month and that month belongs to a specific city. 现在我想检索属于特定月份的日期和该月份属于特定城市的日期。

Database map from Xcode : Xcode的数据库映射:

在此处输入图片说明

Database structure : 数据库结构:

在此处输入图片说明

Any one knows how accomplish this ? 有谁知道如何做到这一点? thanks 谢谢

You can use the SQLiteQueryBuilder class. 您可以使用SQLiteQueryBuilder类。 You can set (and join) the tables using the setTables method. 您可以使用setTables方法设置(和联接 )表。

Sets the list of tables to query. 设置要查询的表列表。 Multiple tables can be specified to perform a join. 可以指定多个表来执行联接。 For example: setTables("foo, bar") setTables("foo LEFT OUTER JOIN bar ON (foo.id = bar.foo_id)") 例如:setTables(“ foo,bar”)setTables(“ foo左外连接bar ON(foo.id = bar.foo_id)”)

Parameters inTables the list of tables to query on inTables中的参数要查询的表的列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM