i have table 10 columns. each column id. example: taskid colorid typeid....
now need take info , "translate" ids "real" content. real content in 10 different tables.table color has color id , color name, table type has id , name , on.
how can in best way besides 9 subqueries inner joins?
my solution is:
select p.*, t3.name (select t1.*, t2.name t1 left join t2 on t1.id=t2.id) p left join on p.id3=t3.i3 and on...
you don't need subqueries when using joins:
select t1.name t1_name, t2.name t2_name, t3.name t3_name, ... referencingtable r inner join table1 t1 on r.id1 = t1.id inner join table2 t2 on r.id2 = t2.id inner join table3 t3 on r.id3 = t3.id ... ; if of referencing columns may not contain links , need return rows anyway, should use outer joins instead, left outer joins:
... referencingtable r left join table1 t1 on r.id1 = t1.id left join table2 t2 on r.id2 = t2.id ...
Comments
Post a Comment