本文介绍了Rails的查询接口where子句中的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是尝试运行SQL查询如下:

i am try to run the sql query as follows

@applicants = Applicant.where("applicants.first_name LIKE ? AND applicants.status = ?", "%#{people}%", ["new", "in-review"] )

我正在一个MySQL错误为:

I am getting an mysql error as :

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

谁能帮我在这
在此先感谢

can anyone help me in this
thanks in advance

推荐答案

您必须使用的MySQL条款

You have to use IN clause of mysql

@applicants = Applicant.where("applicants.first_name LIKE ? AND 
                               applicants.status in (?)", 
                               "%#{people}%", ["new", "in-review"] )

这篇关于Rails的查询接口where子句中的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 09:26