我尝试按以下方式运行sql查询
@applicants = Applicant.where("applicants.first_name LIKE ? AND applicants.status = ?", "%#{people}%", ["new", "in-review"] )
我收到一个mysql错误,如下所示:
ActionView::Template::Error (Mysql2::Error: Operand should contain 1 column(s): SELECT `applicants`.* FROM `applicants` WHERE (applicants.first_name LIKE '%sh%' AND applicants.status = 'new','in-review')):
有人可以帮我吗
提前致谢
最佳答案
您必须使用mysql的IN
子句
@applicants = Applicant.where("applicants.first_name LIKE ? AND
applicants.status in (?)",
"%#{people}%", ["new", "in-review"] )