Active Record Query使用“NOT IN”

时间:2013-09-15 15:06:30

标签: ruby-on-rails

我尝试查询排除作为cookie保存的id的数组列表。

让我陷入困境
where('author_name iLIKE ? OR quote iLIKE ? AND id NOT IN ?', "%#{search}%", "%#{search}%", "#{disable}").all(:order => sorting)

从上面的代码中,它将生成此SQL语句:

SELECT * FROM quotations WHERE author_name LIKE '%' + 'search' + '%' OR quote LIKE '%' + 'search' + '%' AND id NOT IN (1,2,3)

0 个答案:

没有答案