sql拆分字段区分查询

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'

posted @ 2016-08-10 13:24  技术追梦人  阅读(1534)  评论(0编辑  收藏  举报