创建两个表如图: sp_user表: sp_dept表: 目的:通过sp_user的dept_id查询所属部门即sp_dept中的name. 原生sq方法一:select t1.*,t2.name as deptname from sp_user as t1,sp_dept as t2 where t1.dept_id = t2.id; 原生sq方法二:select t1.*,t2.name as deptname from sp_user as t1 left join sp_dept as
关于linq的多表联查效果的实现: 后台多表查询 内连接: SELECT [Extent2].[partID] AS [partID], [Extent1].[userName] AS [userName], [Extent3].[partName] AS [partName]FROM [dbo].[User] AS [Extent1]INNER JOIN [dbo].[User_partB] AS [Extent2] ON [Extent1].[userGUID] = [Extent2].[
多表联查: select p.*,s.Sheng , i.Shifrom [dbo].[ProductRecordInfo] --表名 p left join [ShengInfo] s on p.ShengInfo = s.ShengId --使用left join左连接 让两个表中的指定字段产生连接关系left join [ShiInfo] i on p.ShiInfo = i.ShiId --使用left join左连接 让三个表中的指定字段产生连接关系 这里的