Rails中的Postgres-Queries:不在哪里

时间:2012-07-24 14:48:16

标签: ruby-on-rails postgresql where

我将Rails与PostgreSQL一起使用,它适用于这样的查询:

# 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')

谢谢你的帮助!

1 个答案:

答案 0 :(得分:2)

尝试:

where('NOT ( hstore_column ? :key )', key: 'name_of_key')
相关问题