Efficiently combine two queries with both have a common inner join

keithmulberry

New Member
I would like to join three tables and then union them. Two of the table that are joined are the same in the two queries which are union'd, and it seems like a waste to perform this join twice. See below for an example. How is this best performed? Thanks\[code\]SELECT t1.c1,t2.c1,t3.c1FROM audits AS t1INNER JOIN t2 ON t2.t1_id=t1.idINNER JOIN t3 ON t3.t1_id=t1.idWHERE t2.fk1=123UNIONSELECT t1.c1,t2.c1,t4.c1FROM audits AS t1INNER JOIN t2 ON t2.t1_id=t1.idINNER JOIN t4 ON t4.t1_id=t1.idWHERE t2.fk1=123ORDER BY t1.fk1 ASC\[/code\]
 
Top