如何使用 ManagedQuery 连接多个表?
我正在尝试进行查询,从两个表中获取数据,但它不会向我显示任何结果。我知道有一个结果,因为在 SQLite3 中它至少显示一个结果,例如
sqlite> select eventthemename, eventtypename from event_type, event_theme
...> where event_type.eventthemes = event_theme._id
...> and event_type._id = '2';
Tribal | Dance
我正在使用内容提供程序。有人知道如何制作这个吗?
I'm trying to make a query where I get data from two tables but it won't show me any result. I know there is a result because in SQLite3 it displays at least one, e.g.
sqlite> select eventthemename, eventtypename from event_type, event_theme
...> where event_type.eventthemes = event_theme._id
...> and event_type._id = '2';
Tribal | Dance
I'm using a content provider. Does anyone have an idea on how to make this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题不太清楚(您应该包含一些代码!),所以我可能不会按照您希望的方式回答您的问题。但以下是我在一个查询中连接两个表的一个简单示例:
请注意,此函数中可能有很多可以优化的内容,但它说明了如何完成此操作。
Your question isn't really clear (you should include some of your code!), so I might not answer your question as you hoped. But following is a simple example I have where I join two tables in one query:
Note that there are probably many things that could be optimized in this function, but it illustrates how it can be done.
当我使用内容提供商时,我最终做了一些不太快但有效的事情:
As I'm using content providers I ended doing something not quite fast but that works: