SQL笔记1-连接查询 join

一、总结:数据库连接分为inner join(内连接)、left join(左连接)、right join(右连接)、full join(全连接)四种
二、用法:
1、两张表连接查询
select table1.column,table2.column from table1 join table2 on table1.column1=table2.column2;
2、当存在多张表连接时,直接多个连接查询连接即可
select table.column,table2.column,table3.column from table1 left join table2 on table1.column1=table2.column2 left join table3 on table2.column3=table3.column4…
三、详细说明
1、inner join内连接 返回两张表同时满足on条件的数据 与join是相同的 与直接两张表关联查询也是一样的;

2、left join左连接 返回左表的全部数据,即使右表存在不满足on条件的数据 ;

3、right join 右连接 返回右表的全部数据,即使左表中存在不满足on条件的数据;

4、full join 全连接 将左表和右表的数据全部返回,即使存在不满足on条件的数据。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值