首页 > 其他 > 详细

stuff使用感悟

时间:2018-07-31 20:13:38      阅读:177      评论:0      收藏:0      [点我收藏+]

 

select 
STUFF((select ,+Convert(varchar(10),t2.CityId) from t t2 where not exists(
select top 1 1 from Web_UserCity uc where UserName=user001 and uc.CityId=t2.CityId
 ) for xml path(‘‘)) ,1,1,‘‘)
cityIds2
from t
where not exists(
select top 1 1 from Web_UserCity uc where UserName=user001 and uc.CityId=t2.CityId
 )

注意假如表中只有一个字段时,写stuff时,不要盲目乱加条件。

stuff使用感悟

原文:https://www.cnblogs.com/Tpf386/p/9397908.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!