业务表 Business 业务ID BusinessID 业务编码 BusinessCode 业务名称 BusinessName 集团名称 GroupName 业务类型 BusinessType 承载类型ID BearerTypeID 记录创建时间 CreatedOn 记录修改时间 ModifiedOn 员工表 Employee 员工ID EmployeeID 组ID EmployeeGroupID 用户名 EmployeeUsername 密码 EmployeePassowrd 员工姓名 EmployeeName 员工电话 EmployeeTel 员工状态 EmployeeStatus 员工职位 EmployeePosition 所在部门 EmployeeDepartment 记录创建时间 CreatedOn 记录修改时间 ModifiedOn 网服表 ServiceManage网服ID ServiceManagerID业务ID BusinessID 员工ID EmployeeID 关系 Relation (1,2,3) 要的结果业务名称 集团名称 Relation =1员工姓名 Relation =2 员工姓名 Relation =3 员工姓名SELECT bu.BusinessName, (SELECT em.EmployeeName FROM ServiceManager sm LEFT JOIN Employee em ON sm.EmployeeID = em.EmployeeID WHERE sm.BusinessID = bu.BusinessID and sm.Relation = 1) AS ServiceManageNameA, (SELECT em.EmployeeName FROM ServiceManager sm LEFT JOIN Employee em ON sm.EmployeeID = em.EmployeeID WHERE sm.BusinessID = bu.BusinessID and sm.Relation = 2) AS ServiceManageNameB, (SELECT em.EmployeeName FROM ServiceManager sm LEFT JOIN Employee em ON sm.EmployeeID = em.EmployeeID WHERE sm.BusinessID = bu.BusinessID and sm.Relation = 3) AS ServiceManageNameC FROM Business bu刚自己想了个,不过有问题求改
2 回答
Oo浮云oO
TA贡献7条经验 获得超0个赞
<table> <tr> <th>功通</th> <th>业务名称</th> <th>带宽</th> <th>集团名称</th> <th>承载类型</th> <th>区域类型</th> <th>联系人</th> <th>联系电话</th> <th>网服经理(A角)</th> <th>联系电话</th> <th>网服经理(B角)</th> <th>联系电话</th> <th>客户经理</th> <th>联系电话</th> </tr>
添加回答
举报
0/150
提交
取消