i am working on the following query:-
SELECT group,item,buffer,stock,(stock-buffer) AS shortexcess
FROM stkmain, stkbalance, stkbuffer
WHERE stkmain.item = stkbalance.item
AND stkmain.item = stkbuffer.item
this query works fine. i want to add another coloumn of sales coming from ‘sale’ table. the revised query is:-
SELECT group,item,buffer,stock,(stock-buffer) AS shortexcess, quantity
FROM stkmain, stkbalance, stkbuffer, sale
WHERE stkmain.item = stkbalance.item
AND stkmain.item = stkbuffer.item
AND stkmain.item = sale.item
the problem with this query is that it shows only those rows that are appearing in the sale table and not all the rows of the stkmain table.
kindly advise me how should i rectify this query.
Use Left Join on sktmain to get all rows of sktmain.