Welcome Guest, Not a member yet? Register   Sign In
left join confusion ... in mysql lol...
#2

[eluser]Seppo[/eluser]
I'm not sure if all your joins are left - If any of them isn't just remove the "LEFT" word.

Code:
SELECT b.goodsid, sum(b.total) as total_inv, sum(d.total) as total_ci
FROM invoicehd a
LEFT JOIN invoicedt b ON b.invoice_id = a.id
LEFT JOIN creditInvHd c ON c.invoice_id = a.id
LEFT JOIN creditInvDt d ON d.ciid = c.id AND d.goods_id = b.goods_id

WHERE a.id >= $inv1
AND a.id <= $inv2
AND a.invdate >= $date1
AND a.invdate <= $date2
GROUP BY b.goodsid


Messages In This Thread
left join confusion ... in mysql lol... - by El Forum - 06-01-2008, 11:20 PM
left join confusion ... in mysql lol... - by El Forum - 06-02-2008, 05:04 AM
left join confusion ... in mysql lol... - by El Forum - 06-02-2008, 07:50 AM
left join confusion ... in mysql lol... - by El Forum - 06-02-2008, 07:28 PM
left join confusion ... in mysql lol... - by El Forum - 06-03-2008, 05:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB