1 /* 左鏈接 left join 或者 left outer join */ 2 /* 左鏈接 Table_A表數據所有顯示,Table_B根據條件匹配Table_A 匹配上顯示,不然顯示NULL */ 3 SELECT * from Table_A 4 SELECT * from Table_B 5 SELECT * from Table_A a left outer join Table_B b on a.Code = b.Code 6 7 8 9 /* 右鏈接 right join 或者 right outer join */ 10 /* 右鏈接 Table_B表數據所有顯示,Table_A根據條件匹配Table_B 匹配上顯示,不然顯示NULL */ 11 SELECT * from Table_A 12 SELECT * from Table_B 13 SELECT * from Table_A a right join Table_B b on a.Code = b.Code 14 15 16 /*完整外部聯接:full join或full outer join*/ 17 /*完整外部聯接返回Table_A和Table_b中的全部行。當Table_A在Table_B表中沒有匹配行時, 18 則Table_B的選擇列表列包含空值。若是表之間有匹配行,則整個結果集行包含基表的數據值。*/ 19 SELECT * from Table_A 20 SELECT * from Table_B 21 SELECT * from Table_A a full join Table_B b on a.Code = b.Code 22 23 /*內鏈接:join或 inner join*/ 24 /*返回Table_A和Table_B中匹配的列*/ 25 SELECT * from Table_A 26 SELECT * from Table_B 27 SELECT * from Table_A a join Table_B b on a.Code = b.Code 28 29 /* 交差鏈接 cross join */ 30 /*交差鏈接返回的結果是 Table_A 和Table_B表的笛卡爾積(Table_A的行數乘以Table_B的行數) */ 31 SELECT * from Table_A 32 SELECT * from Table_B 33 SELECT Count(*) from Table_A a cross join Table_B 34 SELECT * from Table_A a cross join Table_B