sqlserver中的四大表连接

内连接,全连接,左连接,右连接

1.select * from Atable a inner join Btable b on a.textZ=b.textZ;--内连接两个表符合on条件的循环合并打印
2.select * from Atable a full join Btable b on a.textZ=b.textZ;--全连接两个表符合on条件的循环合并打印,不符合条件的将缺失部分用null补全

sqlserver中的四大表连接_第1张图片
3.select * from Atable a left join Btable b on a.textZ=b.textZ;--左连接在全连接的基础上,以左表为准,左边必须有数据

sqlserver中的四大表连接_第2张图片
4.select * from Atable a right join Btable b on a.textZ=b.textZ;--右连接在全连接的基础上,以右表为准,右边必须有数据

sqlserver中的四大表连接_第3张图片

你可能感兴趣的:(sqlserver)