【发布时间】:2015-04-03 11:47:58
【问题描述】:
短版
什么是仅 SQL 等价于
Workable.includes(:job_types)
.where(job_types: {id: nil})
(Workable.includes(:job_types).where('SQLHERE', nil)形式的答案
加长版
我正在尝试“或”这两个查询:
workables.includes(:job_types)
.where('job_types.id = ?', params[:job_type])
.references(:job_types)
和
Workable.includes(:job_types).where(job_types: {id: nil})
加长版,在下面澄清大卫的问题
Workables have_and_belong_to_many job_types
我正在寻找Workables,其中id 与搜索参数匹配,或者Workable 根本没有job_types。
【问题讨论】:
标签: mysql sql ruby-on-rails