【问题标题】:Postgres-Queries in Rails: where notRails 中的 Postgres 查询:哪里没有
【发布时间】:2012-07-24 14:48:15
【问题描述】:

我在 PostgreSQL 中使用 Rails,它非常适合这样的查询:

# Does hstore_column contain key?

scoped_users = User.where('hstore_column ? :key', key: 'name_of_key')

现在我的问题:如何反转此查询/如何找到所有没有指定特定键的用户?

# I tried this query amongst others, but it does not work:

scoped_users = User.where('hstore_column ? :key = FALSE', key: 'name_of_key')

感谢您的帮助!

【问题讨论】:

    标签: ruby-on-rails postgresql where


    【解决方案1】:

    试试:

    where('NOT ( hstore_column ? :key )', key: 'name_of_key')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-19
      • 1970-01-01
      • 2018-04-13
      • 1970-01-01
      • 2016-07-02
      • 2016-06-14
      • 1970-01-01
      • 2019-01-08
      相关资源
      最近更新 更多