当我使用"或"运算符(Secretary_Job_Title like '%Secretary%' or Secretary_Job_Title like '%Assistant%'
)我返回的值太多了。
如何在以下查询中最好地使用Like语句为秘书和助理?提前致谢!!
SELECT STUFF((SELECT ';' + secretary
FROM [HandshakeProd].[dbo].[sp_attysecrel]
WHERE attorney = 'HC\' + Rtrim(p.EMPLOYEE_CODE)
AND secretary_job_title LIKE '%Secretary%'
FOR XML PATH('')), 1, 1, '') AS [Assistants]
答案 0 :(得分:0)
也许这就是你想要的?
SELECT STUFF((SELECT ';' + secretary
FROM [HandshakeProd].[dbo].[sp_attysecrel]
WHERE attorney = 'HC\' + Rtrim(p.EMPLOYEE_CODE)
AND (secretary_job_title LIKE '%Secretary%' OR secretary_job_title LIKE '%Assistant%')
FOR XML PATH('')), 1, 1, '') AS [Assistants]