2013-05-17 159 views
3

如何在rails/active record中執行聯合(外部聯接)查詢?Rails Union查詢

... 
    FROM `parents` 
    LEFT JOIN `child` on parents.child_id = child.id 
UNION 
... 
    FROM `parents` 
    RIGHT JOIN `child` on parents.child_id = child.id 

ORDER BY rate desc, grade desc, date desc; 

..使用Model.joins()?

回答