1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > getting joins

getting joins

时间:2022-02-27 14:01:58

相关推荐

getting joins

select * from a innner join b on a.id = b.id

内联合只生成同事匹配a和b的记录集,即a和b的子集

select * from a full outer join b on a.id = b.id

全外联合生成表a和b的记录全集,包括两边都匹配的记录,如果有一边没有匹配的,缺失的这一边为null,即a和b的并集

select * from a left outer join b on a.id = b.id

左外联合生成表a的所有记录,包括在表b里匹配的记录,如果没有匹配的,右边将是null

select * from a left join a on a.id = b.id where b.id is null

为了生成只在表a里而不再表b中的记录集,我们用同样的左外联合,然后用where 语句 排除 我们不想要的记录

select * from a full outer join b on a.id =b.id where a.id is null or b.id is null

为了生成对于表a和表b唯一的记录集,我们 用同样的全外联合,然后用where 语句排除两边都不想要的记录。

select * from a cross join b

其实就是a的每条数据和b的每条数据进行重新组合的最大集合。

即 a的数量*b的数量

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。