34,575
社区成员
发帖
与我相关
我的任务
分享
select count(PlantID ) from Plant join appuser on AppUser .UserUID = Plant.UserUID
where AppUser.Path like (select Path+lTrim(str(AppUser .UserID))+'/%' from AppUser where UserUID=@userUID) or Plant.UserUID=@userUID
declare @userUID uniqueidentifier
set @userUID='12488224-a498-45d6-b23b-39f35a0defcc'
declare @path varchar(255)
set @path=(select Path+lTrim(str(appuser.UserID))+'/%' from AppUser where UserUID=@userUID)
select count(PlantID ) from Plant join AppUser on AppUser .UserUID = Plant.UserUID
where AppUser.Path like @path or Plant.UserUID=@userUID
select count(PlantID ) from Plant join appuser on AppUser .UserUID = Plant.UserUID
where AppUser.Path like (select Path+lTrim(str(AppUser .UserID))+'/%' from AppUser where UserUID=@userUID) or Plant.UserUID=@userUID
--这种写法是不行的,如果子查询出现多个数据集,就会报错