Sql如何写外连接

exists sql 返回结果集为真)  
not exists (sql 不返回结果集为真)

 

已有两张表(t_a和 t_b):

          

左外连接

  1. select * from t_a  a  left join   t_b  b   on a.id=b.id;

  2. select * from t_a  a ,  t_b  b   where a.id=b.id(+);

右外连接

  1. select * from t_a a     right join    t_b b    on a.id = b.id;
  2. select * from t_a a  ,  t_b b    where    a.id(+)=b.id;

完全外连接

select * from   t_a a    full join    t_b b    on    a.id=b.id;

等值连接

  1. select * from   t_a a , t_b b   where   a.id=b.id;
  2. select * from   t_a a   join   t_b b    on a.id=b.id;   --等值连接也可以这样写

猜你喜欢

转载自blog.csdn.net/yuqilin520/article/details/83181716
今日推荐