left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录
right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录
inner join(等值连接) 只返回两个表中联结字段相等的行
有下面两张表
表一:formone
表二 :formtwo
1.left join
返回包括左表中的所有记录和右表中联结字段相等的记录
select * from formone fo left join formtwo ft on fo.id = ft.id;
或
select * from formone fo ,formtwo ft where fo.id = ft.id(+);
得到的结果是:
2.right join
返回包括右表中的所有记录和左表中联结字段相等的记录
select * from formone fo right join formtwo ft on fo.id = ft.id;
或
select * from formone fo ,formtwo ft where fo.id(+) = ft.id;
得到的结果是:
3.inner join
只返回两个表中联结字段相等的行
select * from formone fo inner join formtwo ft on fo.id = ft.id;
或
select * from formone fo ,formtwo ft where fo.id = ft.id;
得到的结果是: