34,590
社区成员
发帖
与我相关
我的任务
分享
update #T set countItem =(Select Count(B.Id) from TbA A,tbb B
where #T.UserId = A.userId
group by A.userId)
没关系
declare @i int = (Select Count(B.Id) from TbA A,tbb B
where XXXXXXXX
group by A.userId)
update #T set countItem =@i
update #T set countItem =(Select Count(B.Id) from TbA A,tbb B
where XXXXXXXX --如果CoutnItem和这个搜索有关系,这里where条件加上,如果没关系,可以这样写,也可以外边定义一个变量
group by A.userId)
;with cte as (
Select A.UserID,Count(B.Id) as CountItem from TbA A,tbb B
where XXXXXXXX
group by A.userId
)
Update#t
Set CountItem=cte.CountItem
from cte
where #t.userId=cte. userId