通过在rails3中使用IN运算符来查找位置。
|
我正在尝试运行如下所示的sql
select name from appointments where location_id in (2,3,4)
以下不起作用。我正在使用PostgreSQL
a = [2,3,4]
Appointment.select(:name).where(\"location_id IN ?\", a)
ActiveRecord::StatementInvalid: PGError: ERROR: syntax error at or near \"2\"
LINE 1: ... FROM \"appointments\" WHERE (location_id IN 2,3,4)
^
: SELECT name FROM \"appointments\" WHERE (location_id IN 2,3,4)
没有找到相关结果
已邀请:
2 个回复
戒黑恳农
希望这可以帮助
炬卤遁蝎变
即在
周围放括号。