如一个表A一个类型字段记录为5XFZ-25表B中类型字段记录为5XFZ-25、5XFZ-80、5BC2412  怎么判断B包含A的。B中的类型都是以顿号隔开的字符串。怎么比较

解决方案 »

  1.   

    charindex('、'+'5XFZ-25'+'、','、'+'5XFZ-25、5XFZ-80、5BC2412'+'、')>0若以上条件成立则包含,反之则不包含
      

  2.   

    --1
    select a.* , b.* from a , b where 
    charindex('、' + a.col + '、' , '、' + b.col + '、') > 0--2
    select a.* , b.* from a , b where 
    '、' + b.col + '、' like '%、' + a.col + '、%' 
      

  3.   

    或者干脆去掉顿号--1
    select a.* , b.* from a , b where   charindex(a.col , replace(b.col,'、','') > 0--2
    select a.* , b.* from a , b where  replace(b.col,'、','') like '%' + a.col + '%'