我总是看到像
SELECT *
FROM Orders
LEFT JOIN OrderLines ON OrderLines.OrderID=Orders.ID
AND Orders.ID = 12345
如何写如
SQL join: where clause vs. on clause
$followers = [['id'=>0], ['id'=>1]];
rails中的ActiveRecord。
答案 0 :(得分:0)
您可以执行以下查询:
Order.joins("LEFT JOIN order_lines ON order_lines.order_id=orders.id
AND orders.id = 12345")