select a.biaoti,a.laiyuan,b.* from sab_xwgg as a join yhgl as b on charindex(cast(b.dm as nvarchar(max))+';',a.dm)>0 where b.dm='1'
加上全部为0时的显示
select a.*,b.xm from sab_xwgg as a join yhgl as b on (charindex(cast(b.dm as nvarchar(max))+';',a.dm)>0 or a.dm='0') INNER JOIN YHGL ON a.tjrid=YHGL.dm where b.dm='1'