sql server 学习--简单的sql server查询语句2-join on查询记录

三表join on 综合查询:

select
e.EmpNo, u.LoginName ,e.Id , u.LoginPwd , u.Id ,r.Id
from [dbo].[SYS_User] u
join [dbo].[SYS_Role] r on r.id=u.SYS_Role_Id
join [dbo].[OA_Employee] e on u.Id=e.SYS_User_Id
where u.DataState=‘0’ and e.SYS_User_Id !=’’

且结果进行验证:

select e.EmpNo,s.LoginName,e.Id,s.LoginPwd,s.Id from [dbo].[SYS_User] s
join [dbo].[OA_Employee] e
on s.Id=e.SYS_User_Id where e.SYS_User_Id !=’’;

select u.LoginName ,r.id from [dbo].[SYS_User] u
join [dbo].[SYS_Role] r
on r.id =u.SYS_Role_Id where u.DataState=‘0’ and u.SYS_Role_Id !=’’;

记录学习.

你可能感兴趣的:(学习类)