Xlenem
Xlenem

Reputation: 13

How to select columns from two different tables, which meet conditions based on third table

this is my problem (in MS SQL SMS 2008 R2):
I have two tables:
table1 with columns id1 name1
table2 with columns id2 name2
I also have third temporary table made from imported xls with columns name1, name2
what i want is to have select that will result in something like copy of that temporary table but with id1, id2 instead of name1, name2.
Is that even possible?

Upvotes: 0

Views: 70

Answers (1)

radar
radar

Reputation: 13425

you need to use left join with two tables

select id1, id2
from tempTable T
left join table1  T1
on T.name1 = T1.name1
left join table2 T2
on T.name2 = T2.name2

Upvotes: 1

Related Questions