日期:2014-05-17 浏览次数:20777 次
--写成A.xx=C.xx 就是A C外连,沒錯!
--写成B.xx=C.xx 應該是A及B同時與C外连
--也許用下面的測試結果你會更清楚:
CREATE TABLE #t1 (a1 CHAR(1))
INSERT #t1 SELECT 'A'
INSERT #t1 SELECT 'B'
CREATE TABLE #t2 (a1 CHAR(1))
INSERT #t2 SELECT 'A' UNION ALL SELECT 'C'
CREATE TABLE #t3 (a1 CHAR(1))
INSERT #t3 SELECT 'A' UNION ALL SELECT 'B' UNION ALL SELECT 'C'
SELECT a.a1 a_a1,b.a1 b_a1,c.a1 c_a1
FROM #t1 a
LEFT JOIN #t2 b ON a.a1=b.a1
LEFT JOIN #t3 c ON a.a1=c.a1
SELECT a.a1 a_a1,b.a1 b_a1,c.a1 c_a1
FROM #t1 a
LEFT JOIN #t2 b ON a.a1=b.a1
LEFT JOIN #t3 c ON b.a1=c.a1