select id,times=count(*)
from table1 a,table2 b
where charindex(','+a.id+',',','+b.name+',')>0
group by id

解决方案 »

  1.   


    select a.id, count(*) as times
    from table1 a , table2 b
    where charindex(','+a.id+',' , ','+b.name+',')>0
      

  2.   


    select a.id, count(*) as times
    from table1 a , table2 b
    where charindex(','+a.id+',' , ','+b.name+',')>0
    group by a.id
      

  3.   

    where charindex(','+a.id+',' , ','+b.name+',')>0
    为什么a.id前后要加','+呢,不加
    不是也可以实现吗
    谢高手赐教
      

  4.   

    如果table2中出现这样的字段又该怎么办啊??a,b,a,aa,b,c