Trouble with a simple inner join for multiple tables

Doloagota

New Member
My tables:\[code\]db_supply (Main supplier information data table) -----------------------------------------------| Supplier_ID | Supply_Type_ID | Itm_ID | Stock ||-----------------------------------------------|| 1 | 1 | 33 | 3 ||-----------------------------------------------|| 2 | 2 | 28 | 1 | -----------------------------------------------lookup_supplier -----------------------------| Supplier_ID | Supplier_Name ||-----------------------------|| 1 | Walter ||-----------------------------|| 2 | Jesse | -----------------------------lookup_supply_type -----------------------------------| Supply_Type_ID | Supply_Type_Name ||-----------------------------------|| 1 | Import ||-----------------------------------|| 2 | Delivery | -----------------------------------lookup_itm ------------------------| Itm_ID | Itm_Name ||------------------------|| 33 | Pickles ||------------------------|| 28 | Burger | ------------------------lookup_supply_speed -----------------------------| Supplier_ID | Supplier_Speed ||------------------------------|| 1 | Fast ||------------------------------|| 2 | Slow | ------------------------------A query for 'Burger' will output this table: ----------------------------------------------------------------------| Supplier_Name | Supply_Type_Name | Itm_Name | Stock | Supplier_Speed ||----------------------------------------------------------------------|| Jesse | Delivery | Burger | 1 | Slow | ----------------------------------------------------------------------\[/code\]Problem: I can't produce an SQL statement that would get me the \[code\]Supplier_Speed\[/code\] column since the \[code\]lookup_supply_speed\[/code\] does not have any FK association to \[code\]db_supply\[/code\] (all the other tables do).SQL below will give me this: (WE QUERY FOR \[code\]Itm_Name\[/code\] e.g. \[code\]Burger\[/code\])\[code\] -----------------------------------------------------| Supplier_Name | Supply_Type_Name | Itm_Name | Stock ||-----------------------------------------------------|| Jesse | Delivery | Burger | 1 | -----------------------------------------------------SELECT b.Supplier_Name, c.Supply_Type_Name, d.Itm_Name, a.StockFROM db_supply a INNER JOIN lookup_supplier b ON a.Supplier_ID = b.Supplier_ID INNER JOIN lookup_supply_type c ON a.Supply_Type_ID = c.Supply_Type_ID INNER JOIN lookup_itm d ON a.Itm_ID = d.Itm_IDWHERE d.Itm_Name = 'Burger'\[/code\]How can I modify this so that I can join \[code\]lookup_supplier\[/code\] with \[code\]lookup_supply_speed\[/code\] and then join it to the rest?SQLFiddle: http://www.sqlfiddle.com/#!2/9635d/3
 
Top