SQLTeam.com | Weblogs | Forums

Looking up values in order to do multiple joins

How would you do a Select statement to lookup a value in a table and then use that value to lookup another value in another table which is then used to lookup a third value in a third table? I cannot do a join from my initial table as there is no common matching field to do the join on.
In my dataset I have an Instr_Id which is the only possible way to eventually get the Legal_Id but the table where the Legal_Id is stored does not have a Instr_Id.

Example:

I use Instr_Id in tbl.ABC and join to Instr_Id in tbl.DEF in order to get the Fin_Enty_Name . I then need to use this Fin_Enty_Name value to join to tbl.GHI to get the Fin_Enty_Id . I finally then need to use this Fin_Enty_Id to look up the Legal_Id in tbl.JKL so that I can show the Legal_Id for each Instr_Id

Please provide sample data and example of the final result you want to see

Hi

Select instr_id , legal_id from
( Select * from
ABC join Def on
Instr_id
) Ok
Join
( Select * from ghi join jkl
On
Fin_entity_id
) Ok123
On ok.fin_entity_name = ok123.fin_entity_name