- 内连接 inner join
说明:(典型的联接运算,使用像 = 或 <> 之类的比较运算符)。包括相等联接和自然联接。内联接使用比较运算符根据每个表共有的列的值匹配两个表中的行。例如,检索 students和courses表中学生标识号相同的所有行。
select a.*,b.* from a inner join b on a.id=b.parent_id
或者是:
select a.*,b.* from a,b where a.id=b.parent_id
select a.*,b.* from a left join b on a.id=b.parent_id
或者是
select a.*,b.* from a,b where a.id=b.parent_id(+)
- 右连接 right join
说明:右向外联接是左向外联接的反向联接。将返回右表的所有行。如果右表的某行在左表中没有匹配行,则将为左表返回空值。
select a.*,b.* from a right join b on a.id=b.parent_id
或者是
select a.*,b.* from a ,b where a.id(+)=b.parent_id
- 全连接 full join
说明:完整外部联接返回左表和右表中的所有行。当某行在另一个表中没有匹配行时,则另一个表的选择列表列包含空值。如果表之间有匹配行,则整个结果集行包含基表的数据值。
select a.*,b.* from a full join b on a.id=b.parent_id