内连接、外连接、交叉连接、联合连接

内连接

inner join on / inner outer join on
隐式内连接:select * from table1,table2 where table1.id= table2.id;
标准内连接:select * from table1 inner join table2 on table1.id= table2.id;
自然连接:select * from table1 natural join table2;(笛卡尔积=所有可能的组合)

外连接

1.左连接(左外连接)
left join on / left outer join on
显示左表(table1)中的所有记录,显示右表(table2)中符合搜索条件的记录,右表记录不足的地方都为null;
- select * from table1 left join table2 on table1.id= table2.id;

2.右连接(右外连接)
right join on / right outer join on
显示右表(table2)中的所有记录,显示左表(table1)中符合搜索条件的记录,左表记录不足的地方都为null;
- select * from table1 right join table2 on table1.id= table2.id;

3.全连接(全外连接)(完全连接)
full join on / full outer join on

交叉连接

cross join (不带on字句)(笛卡尔积)
返回左表中的所有行,左表中的每一行与右表中的所有行组合。交叉连接接也称作笛卡尔积。
隐式的交叉连接,没有cross join
显式的交叉连接,使用cross join

联合连接(union join)

找出全外连接和内连接之间差异的所有行。这在数据分析中排错中比较常用。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值