Android 2.2 (Froyo) SQLite 缺少一些 IN 子句功能?
最近,我将 Nexus One 更新为 Froyo (2.2),我注意到 SQLite 的一些明显不同的行为。
例如,我一直使用子查询(返回字符串数据)作为 IN 子句的一部分,并且子查询部分似乎不再正常运行。我附上了一个使用下面的联系人数据库的 SQL 查询示例(直接查询仅用于说明目的):
SELECT _id FROM data WHERE display_name IN (SELECT display_name FROM contacts);
在 Android 2.1 之前,这不是问题。但是,更新后,这会返回一个空记录集,除非我单独运行子查询,将每个结果值用单引号引起来,并将这些值直接附加到 IN 子句中。
我注意到我正在开发的多个应用程序中存在这种功能损失,但我应该注意,当结果是数字而不是基于字符串时,它似乎确实有效。
还有其他人遇到过这个问题吗?
Recently I updated my Nexus One to Froyo (2.2) and I've noticed some significantly different behavior with SQLite.
For example, I had been using a subquery (returning string data) as part of an IN clause, and the subquery portion no longer appears to function correctly. I've attached an example SQL query working with the contacts database below (Direct query shown for illustrative purposes only):
SELECT _id FROM data WHERE display_name IN (SELECT display_name FROM contacts);
Up until Android 2.1 this was not a problem. After the update however, this returns an empty record set unless I run the subquery separately, surround each of the resulting values in single quotes and append those values directly into the IN clause.
I have noticed this loss of functionality in multiple applications I'm working on, but I should note that it does appear to work when the results would be numeric rather than string based.
Has anyone else run into this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 SQLite 的行为确实发生了变化,您可以尝试使用 EXISTS 运算符重写查询:
这消除了对 IN 运算符的依赖。
If the behaviour of SQLite has indeed changed, you could try re-writing the query using the
EXISTS
operator instead:This removes the dependence on the
IN
operator.