假设有部门表(DeptTB):
用户表(UserTB):
1、Join (Inner Join)
如:
SELECT * FROM dbo.UserTB JOIN dbo.DeptTB ON dbo.UserTB.deptId=dbo.DeptTB.deptId结果:
2、Left Join
如:
SELECT * FROM dbo.UserTB LEFT JOIN dbo.DeptTB ON dbo.UserTB.deptId=dbo.DeptTB.deptId结果:
3、Right Join
如:
SELECT * FROM dbo.UserTB RIGHT JOIN dbo.DeptTB ON dbo.UserTB.deptId=dbo.DeptTB.deptId
结果:
4、Full Join
如:
SELECT * FROM dbo.UserTB FULL JOIN dbo.DeptTB ON dbo.UserTB.deptId=dbo.DeptTB.deptId
结果: