sql server - using joins how to compare 2 columns -
i have 2 tables
table1:
id name 1 os 2 harddisk 3 ram 4 windows 5 linux 6 solaris 7 mac 8 unix 9 dcci
table2:
id table1_id table1_component 1 1 4 2 1 5 3 1 6 4 1 7 5 1 8 6 1 9
i want join above 2 tables , need output put
table1_id table1_component os windows os linux os solaris os mac os unix os dcci
please me, instead of numbers in table 2
need names table1
you need join on table1
twice result:
select t1.name table1_id, c.name table1_component table1 t1 inner join table2 t2 on t1.id = t2.table1_id inner join table1 c on t2.table1_component = c.id
see sql fiddle demo
Comments
Post a Comment