SQL Server Pre-joining two tables before joining to master table

bvhaajcl  于 2023-10-15  发布在  其他
关注(0)|答案(1)|浏览(109)

I have three tables as outlined below:

  • Primary Table

  • primary table key

  • primary data

  • Secondary Table

  • primary table key

  • secondary table key

  • secondary data

  • Tertiary Table

  • secondary table key

  • tertiary data

Due to server restrictions, I cannot create new tables, which could resolve this, but I must join these three tables.

I need to get data from both Secondary and Tertiary table into the Primary table, but there is no direct link between the Tertiary Table and the Primary one, only with the Secondary.

So I think I need to join the Secondary and Tertiary tables, while selecting only the relevant columns, before I add them to the Primary. Or am I missing something obvious?

c7rzv4ha

c7rzv4ha1#

Nevermind, it's just a regular join on top of the existing one from what I can see.

... 
Join Table 2 T2 ON T1.Primary_table_key = T2.primary_table_key
Join Table 3 T3 ON T2.Secondary_table_key = T3.secondary_table_key

相关问题