前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Basic Join Operation--comma-separated join

Basic Join Operation--comma-separated join

作者头像
马克java社区
修改2021-05-18 14:26:19
2880
修改2021-05-18 14:26:19
举报
文章被收录于专栏:java大数据java大数据

Basic Join Operation--comma-separated join(叉乘,都乘到N*M,N,M分别是两个表的条数)

马克-to-win:  select * from register, student;

Cross Join(叉乘,都乘到N*M,N,M分别是两个表的条数)---same as comma-separated join

select * from register CROSS JOIN student;

select r.name, s.name,s.age from register r CROSS JOIN student s where r.id = s.id AND s.age >20;

INNER JOIN

交叉联接的作用同内联接一样。例如,下面的 Transact-SQL 查询得到相同的结果集: 

select * from register INNER JOIN student;

select r.name, s.name,s.age from register r INNER JOIN student s on r.id = s.id AND s.age >20;

 

OUTER JOIN

Left join

Return all matched rows and all unmatched rows from the left table

Right join

Return all matched rows and all unmatched rows from the right table

Full join

Return all matched and unmatched rows from both tables

select * from register as r left join student as s on r.id = s.id;

select * from register as r right join student as s on r.id = s.id;

select * from register as r full join student as s on r.id = s.id;(mysql不支持full join)

比较:inner join,cross join,join只是找回所有符合条件的行,不基于谁,不返回null。但外交不一样, Left join时,左表全回来,右表用null补上,见目录里的例子。

 

更多请看下节:https://blog.csdn.net/qq_44591615/article/details/109205413

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档