表连接

多表连接:
1.Natural join:  --两表连接
[自动匹配两个表中,列名和数据类型都相同的列(多列列名相同就匹配多列)]
[select_list中的col_name不能加前缀]
– USING clause  
    --只能join,不能写natural join;
    --using(两表中相同列列名)
    --using中的列名在where子句中不能加前缀
    --using中的列在select_list中不能加前缀
– ON clause
    --on ta.id1 = tb.id1
    --使用了on 后,在select_list中必须加前缀

2.Inner join:  --多表连接
    --ta inner join tb on(ta.id1= tb.id1) inner join tc on(tb.id1= tc.id1)

3.from ta,tb,tc
  where ta.id1= tb.id1
    and tb.id1 = tc.id1

4.自连接:
select last_name "EMPLOYEES",last_name "MANAGER"
FROM hr.employees emp join hr.employees mgr
ON (emp.manager_id = mgr.employee_id)
;

5.不等连接:Nonequijoins
外连接: outer join
– LEFT OUTER join  --左边full,右边null
– RIGHT OUTER join --右边full,左边null
– FULL OUTER join

6.笛卡尔积: cross join 

posted @ 2015-07-19 12:32  si_sier  阅读(151)  评论(0编辑  收藏  举报