SQL join data from two tables with multiple data from one table -
i have 2 tables, first 1 set this:
name(pk), height, width, age
the second tables set this:
name1, name2
how go joining 2 tables 2 eachother output data in following way:
name1, name2, height1, height2, width1, width2, age1, age2
name in first table can joined on name in second table.
you place table1 (with name, height, width, age values in each row) query twice different alias names. i'm sure analysis of performance in order possible outer joins both table1 references (t11 , t12) in case name1 or name2 values in table2 (t2) not exist in table1 (t11 , t12).
select t2.name1, t2.name2, t11.height height1, t12.height height2, t11.width width1, t12.width width2, t11.age age1, t12.age age2 table2 t2, -- contains rows name1, name2 table1 t11, -- contains rows name, height, width, age table1 t12 -- contains same rows t11 name, height, width, age t12.name = t2.name2 , t11.name = t2.name1
Comments
Post a Comment