data = Program.joins(:program_schedules, :channel).
where(
"program_schedules.start" => options[:time_range],
"programs.ptype" => "movie",
"channels.country" => options[:country]).
where("programs.official_rating >= ?", options[:min_rating]).
group("programs.id").
order("programs.popularity DESC")
此查詢只檢索「程序」表(我認爲是因爲「group by」子句)。 如何從所有表格(程序,programs_schedules,通道)中檢索所有數據?獲取所有表(Postgresql)的所有數據
類節目<的ActiveRecord ::基地
belongs_to的:通道
的has_many:program_schedules
Ruby on Rails的3.2
PostgreSQL的9.2
也許你應該檢查(向我們展示)生成的查詢。 – wildplasser
如何打印生成的sql查詢? – sparkle
我不知道。 RoR是你的玩具。你總是可以從postgres日誌中取出它。 – wildplasser