62,243
社区成员




select typename 类型,个数=(select t.typename+'的人'+rtrim(count(1))+'个' from tuser where charindex(','+rtrim(t.id)+',',','+types+',')>0) from ttype t
select tType.typename AS 类型, tType.typename +'的人' + cast(count(1) as varchar(10)) + '个' AS 个数 from tType
, tUser where ',' + tUser.ttypes + ',' LIKE '%, + cast(tType.id as varchar(10)) + ',%'
group by tType.id, tType.typename
select tType.typename AS 类型, tType.typename +'的人' + cast(count(1) as varchar(10)) + '个' AS 个数 from tType
join tUser where ',' + tUser.ttypes + ',' LIKE '%, + cast(tType.id as varchar(10)) + ',%'
group by tType.id, tType.typename
性能不会很高,所以建议你修改表结构,再加一个表 tUser与tType关系的表