declare @TypeName varchar(50)
set @TypeName='类型'
select count(*)
from tableB a
join (select TypeId from tableC where TypeName like @TypeName+'%') b on a.TypeId=b.TypeId

解决方案 »

  1.   

    select count(1) from tablec a inner join tableB b on a.TypeId  = b.TypeId where a.TypeName like'%xxx%'
      

  2.   

    select b.Id,b.TypeId,c.TypeName,(select count(*) from tableB b,tableC c where c.TypeId=b.TypeId where c.TypeName like '%类型%') s 
     from tableB b,tableC c where c.TypeId=b.TypeId and c.TypeName like '%类型%'