ID USER
1 [空]
2 1,2
3 3,4,5
4 [空]
当 user 为空时,执行效果为 select * from table
当 user 不为空时,执行效果为 select * from table where charindex(','+user+',',变量)意思就是:user 是用户权限表,如果指定了用户ID,则只有指定的用户才能访问,如果没有指定用户ID,则所有人都能访问。菜鸟拜谢高手解答
1 [空]
2 1,2
3 3,4,5
4 [空]
当 user 为空时,执行效果为 select * from table
当 user 不为空时,执行效果为 select * from table where charindex(','+user+',',变量)意思就是:user 是用户权限表,如果指定了用户ID,则只有指定的用户才能访问,如果没有指定用户ID,则所有人都能访问。菜鸟拜谢高手解答
union all
select * from table where USER is not null and charindex(','+user+',',变量)