Forum Moderators: coopster

Message Too Old, No Replies

querying data from 3 tables based on 4rd table

select syntax 2 tables linked to third

         

djinji

12:01 am on Feb 27, 2005 (gmt 0)



hello

I have a table 'parts' which lists my inventory. There is an 'idmfg' in that table which links to 'mfg.idmfg' which holds different companies info. I have another table 'stores' which hold the data on places I buy these things from. I created a table called 'sku' and it holds 'idparts' and 'idstores' and also the 'sku' and 'cost'.
I am trying to create a query that shows all the stores that I purchased a certain sku. Something like

SELECT mfg.company, parts.item, stores.company, stores.city, sku.sku, sku.cost FROM mfg,parts,stores,sku WHERE sku.idsku=$_POST['skuid'] AND sku.idstores=stores.idstores AND sku.idparts=parts.idparts AND mfg.idmfg=parts.idmfg;

i get 148000 results all duplicates
basically how would I get the info from the mfg table from the link in the parts table from my query to the sku table and only the stores where I can purchase the item.

i hope that is clear i assume I need a subquery or something but the book I have is unclear on a practical application of that function.

jamie

10:01 pm on Feb 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi djinji,

my head spins just trying to understand your question ;-)

have you tried select DISTINCT(stores.company)?