查询是这样的
对输入的B在字段A中进行查询.表Tabel1
ID    A 
1     中国,美国,日本
2     加拿大,中国
...
n     美国,英国对B的值为中国,英国要求输出结果为,包含中国或英国的行,谢谢,希望得到效率较高的代码

解决方案 »

  1.   

    select *
    from table1
    where charindex(','+'中国,英国'+',',','+A+',') > 0 or charindex(','+'英国,中国'+',',','+A+',') > 0
      

  2.   

    select * from table1 where a like '%中国%' or a like '%英国%' 
      

  3.   

    declare @tb table (id int,a varchar(20))
    insert into @tb select 1,'中国,美国,日本'
    insert into @tb select 1,'加拿大,中国'
    insert into @tb select 1,'美国,英国'
    insert into @tb select 1,'美国'select * from @tb where a like '%[中,英][国]%'
    2字的可以
      

  4.   


    select *
    from table_1
    where index(a,'中国') > 0 or index(a,'英国') > 0;