--try
select * from grp a where
exists (select 1 from usename where usename='1' and
charindex(','+cast(a.id as varchar)+',',','+fwdetail )>0)
select * from grp a where
exists (select 1 from usename where usename='1' and
charindex(','+cast(a.id as varchar)+',',','+fwdetail )>0)
select * from grp where charindex(id,(select fwdetail from usename where usename='1'))>0
在in后面好象一定要象'1','2','3'这样,
select * from grp where id in ('1','2','3')就可以.
select @s=cast(fwdetail as varchar(1000)) from usename where usename='bbb'
select * from grp where charindex(','+cast(id as varchar)+',',@s)>0
这样可以了,但是有个问题是第一条记录读不出来.因为数是1,2,3,4 而','+cast(id as varchar)+','是,1,