select
(select ifnull(sum(registerAmount),0)
from register where register.orderID = orders.orderID) as theTotal
from orders
left join register on orders.orderID = register.orderID
where orders.customerID = 17 and invSent = true
顯示8行... 5含有0-3沒有。
如果我添加
group by orders.customerID
我得到一個包含零一行。
我如何得到一行包含總數?
left OUTER join? – Randy