I want to know how to join Pro_ID and location ID with multiple tabel

Viewed 7

I wrote this code, but answer is not correct.

Select location_tbl.location,product_tbl.pro_name,SUM(purchase_tbl.Qty),SUM(stock_tfr_tbl.Qty)From(((purchase_tbl,stock_tfr_tbl)RIGHT OUTER join product_tbl ON (purchase_tbl.item_ID OR stock_tfr_tbl.Item_Id) = product_tbl.ID)RIGHT OUTER Join location_tbl ON (purchase_tbl.Location_ID OR stock_tfr_tbl.TFR_TO) = location_tbl.ID)GROUP BY  location_tbl.location,product_tbl.pro_name;

This is the example table and view

1 Answers

Sorry but to answer ur question u first need to clearly define. You have refered each table primary key as ID. But when u r using that ID into another table u again call it ID. It would be great if u could clearly name each table ID as itemID, storeID so that when u use it another table it is easy to understand. Right now i cannot identify what is the flow in ur data.

Related