在 XML PATH 查询中使用多个 like 语句的最佳方式
Best way to use multiple like statements in XML PATH query
当我使用 "Or" 运算符 (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]
也许这就是你想要的?
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]
当我使用 "Or" 运算符 (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]
也许这就是你想要的?
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]