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_A12 SELECT * from Table_B13 SELECT * from Table_A a right join Table_B b on a.Code = b.Code14 15 16 /*完整外部联接:full join或full outer join*/17 /*完整外部联接返回Table_A和Table_b中的所有行。当Table_A在Table_B表中没有匹配行时,18 则Table_B的选择列表列包含空值。如果表之间有匹配行,则整个结果集行包含基表的数据值。*/19 SELECT * from Table_A20 SELECT * from Table_B21 SELECT * from Table_A a full join Table_B b on a.Code = b.Code22 23 /*内连接:join或 inner join*/24 /*返回Table_A和Table_B中匹配的列*/25 SELECT * from Table_A26 SELECT * from Table_B27 SELECT * from Table_A a join Table_B b on a.Code = b.Code28 29 /* 交差连接 cross join */30 /*交差连接返回的结果是 Table_A 和Table_B表的笛卡尔积(Table_A的行数乘以Table_B的行数) */31 SELECT * from Table_A32 SELECT * from Table_B33 SELECT Count(*) from Table_A a cross join Table_B 34 SELECT * from Table_A a cross join Table_B