且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL多个外部联接(将t-sql联接转换为ANSI格式)

更新时间:2023-11-29 13:29:22

从您的问题中,我想您只希望将t3中的行与t2中的与t1相连的行连接起来:

From your question I guess you only want rows from t3 that join with the rows from t2 that joined with t1:

SELECT 
    * 
FROM
    t1
    LEFT JOIN t2 ON t1.col1 = t2.col1
    LEFT JOIN t3 ON t1.col2 = t3.col1 AND t2.col2 = t3.col2

这将不包括来自t2和t3的行在col2上联接,除非来自t2的行已经与col1上的t1联接.

This will not include rows from t2 and t3 that join on col2, unless the rows from t2 have already joined with t1 on col1.