Left join : Map to SQL « ActiveRecord « Ruby






Left join


Account.find :all,
             :joins => "LEFT JOIN visits ON accounts.id=visits.account"

The result will be the following SQL query:

SELECT * FROM accounts LEFT JOIN visits ON accounts.id=visits.account_id

 








Related examples in the same category

1.The :order parameter defines the sorting order.
2.Group by clause
3.Aggregate function and group by
4.Left join on a column
5.Limit offset