27,579
社区成员
发帖
与我相关
我的任务
分享
--不管事什么版主,都是版主
select * from tb where class1+class2+class3>0
select * from tb where (class1=1 or class2=1 or class3=1)
and uid=....
select Id,UserId,case when class1+class2+class3>0 then '是' else '否' end
from [Table]
create procedure pro_class
@userid int,@class1 int,@class2 int,@class3 int
as
select count(id)
from tb
/*大板块相等前提,小版块相等或为0*/
where userid=@userid and class1=@class1 and (class2=@class2 or class2=0) and (class3=@class3 or class3=0)
go
exec pro_class 102,1,2,3
-----------
1
(1 行受影响)
declare @xx table(id int identity(1,1), userid int, class1 int, class2 int,class3 int )
insert into @xx select 102,1,0,0
union all select 105,2,3,1
union all select 108,1,1,0
select userid,
case
when class1=1 then '大版主'
when class2=1 then '中版主'
when class3=1 then '小版主'
end
from @xx