【问题标题】:Nested query is not supported in SQLiteSQLite 不支持嵌套查询
【发布时间】:2012-03-02 17:16:08
【问题描述】:

我在我的 iPhone 应用程序上使用 SQLite 数据库,我需要执行一个需要嵌套查询的任务。但是,我的查询似乎不起作用,我用谷歌搜索了它,发现 SQLite 不支持子查询。 有什么解决办法吗?

编辑: 这是对我不起作用的查询:

select count(*) from quiz where theme=(select id from theme where nom="Houses") and etat=0;

【问题讨论】:

  • SQLite 支持子查询。你能发布一个不起作用的查询示例吗?
  • 嗨尼克,我已经编辑了我的问题:)

标签: ios sqlite


【解决方案1】:

如果子查询(select id from theme where nom="Houses")返回多行,
theme = 不起作用。您必须改用theme IN

select count(*) from quiz where theme IN (select id from theme where nom="Houses") and etat=0;

【讨论】:

    【解决方案2】:

    您可以使用联接而不是嵌套查询,这样会起作用。

    供参考,请检查这个...

    Nested statements in sqlite

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多