我想加入三个表,然后合并它们。在联合的两个查询中,两个连接的表是相同的,执行两次连接似乎是一种浪费。请参阅下面的示例。这如何表现得最好?谢谢
SELECT t1.c1,t2.c1,t3.c1
FROM audits AS t1
INNER JOIN t2 ON t2.t1_id=t1.id
INNER JOIN t3 ON t3.t1_id=t1.id
WHERE t2.fk1=123
UNION
SELECT t1.c1,t2.c1,t4.c1
FROM audits AS t1
INNER JOIN t2 ON t2.t1_id=t1.id
INNER JOIN t4 ON t4.t1_id=t1.id
WHERE t2.fk1=123
ORDER BY t1.fk1 ASC