查询所有财务部门的所有人员信息
1.子查询 select * from tbl_Personnel_Basic a where Unit in ( SELECT OUID FROM [dbo].[tbl_OU_Basic] WHERE OUName LIKE '%财务%' ); 2.左联 select c.* from ( select b.OUID,b.OUName,b.OUCode,a.* from ( SELECT * FROM [dbo].[tbl_OU_Basic] WHERE OUName LIKE '%财务%') b left join tbl_Personnel_Basic a on a.Unit=b.OUID) c where c.PersonnelId is not null;--注意条件 3.左联 select q.* from ( select b.OUID,b.OUName,b.OUCode,a.* from tbl_Personnel_Basic a left join ( SELECT * FROM [dbo].[tbl_OU_Basic] WHERE OUName LIKE '%财务%') b on a.Unit=b.OUID ) q where q.OUID is not null;--注意条件