SELECT
T1.*,
(SELECT T2.PartName+','
FROM wf_work_items T2
WHERE T1.ProcID=T2.ProcID
FOR XML PATH('')
) as PartName ,
(SELECT T2.PartDeptName+''
FROM wf_work_items T2
WHERE T1.ProcID=T2.ProcID
FOR XML PATH('')
) as PartDeptName
FROM Con_Contract T1我要的是T1 的主键 对应 T2的PartName(多个数据对应一一个主键) 和PartDeptName 但只能生成一条 如图:现在我已经查出来了 就想怎么实现着PartName 和 PartDeptName两个的查询 求解求解
1 回答
你胖到影响我了
TA贡献3条经验 获得超1个赞
select * from ( SELECT T1.BaseContractId, (SELECT T2.PartName+',' FROM wf_work_items T2 WHERE T1.ProcID=T2.ProcID FOR XML PATH('') ) as PartName , (SELECT T2.PartDeptName+'' FROM wf_work_items T2 WHERE T1.ProcID=T2.ProcID FOR XML PATH('') ) as PartDeptName FROM Con_Contract T1) T1 where T1.PartName like '%王%' and T1.PartDeptName like '%道%'
已经自己搞定~~~
- 1 回答
- 0 关注
- 1933 浏览
添加回答
举报
0/150
提交
取消