我有个用户权限表 role,有InfoUserIDs varhcar字段,用来存放有权限的ID值,如 1,3,7,
指的是 ID为1,ID为3,ID为7能够访问,而,这些ID事存放在InfoUser 里面的,
那么我想在InfoUser查找符合权限的数据出来怎样写呢,
听说like能写出来,不知道怎样写呢
指的是 ID为1,ID为3,ID为7能够访问,而,这些ID事存放在InfoUser 里面的,
那么我想在InfoUser查找符合权限的数据出来怎样写呢,
听说like能写出来,不知道怎样写呢
问题是 这 1 3 7 不止这些,以后还会增加的,难道到时又要一个写上去,我的意思是又没办法 将InfoUserIDs 字段分成一个个ID,然后在InfoUser 那里将 InfouserIDs里面有的ID 的信息都显示出来
declare @str varchar(10)
set @str = '1,2,3'select * from tb where charindex(','+ltrim(id)+',',','+@str+',') > 0--orselect * from tb where ','+ltrim(id)+',' like ','+@str+','
select # from infouser where ltrim(id) in (select ltrim(infouserids) from role )