Omn*_*ent 4 postgresql activerecord ruby-on-rails-3
我试图运行如下的SQL
select name from appointments where location_id in (2,3,4)
Run Code Online (Sandbox Code Playgroud)
以下不起作用.我在用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)
Run Code Online (Sandbox Code Playgroud)
你可以用这个:
Appointment.select(:name).where(:location_id => [2,3,4])
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助
| 归档时间: |
|
| 查看次数: |
447 次 |
| 最近记录: |