。一个张表里面有一个Area字段
这个字段保存多个地区。用","分割。
比如:长沙,上海,重庆,南京,开封,杭州查询条件是:湖南,上海,江苏,河南,浙江。
随便输入上面那一个省。只要Area字段包含这个省份下面的市。就要出来相应的数据。要考虑效率问题。。谢谢大家急

解决方案 »

  1.   

    这是一种 select * from tb where  charindex(@area+',',area+',',)>0
      

  2.   

    select * from tb where  charindex(@area+',',area+',')>0 
      

  3.   

     另外一种很繁琐,, 要吧Area 分隔,, 得使用function,, 就不写了,, 
      

  4.   

     运行sql server ,  按f1-->选择检索-->输入charindex---> 回车
      

  5.   

    if object_id('Area1') is not null drop table Area
    create table Area1
    (
      Area varchar(50)
    )
    insert into Area1 select '长沙,上海,重庆,南京,开封,杭州'create proc GetArea
    (
      @Area varchar(30)
    )
    as
    select * from Area1 where charindex(@Area,Area)>0exec GetArea '上海'Area
    --------------------------------------------------
    长沙,上海,重庆,南京,开封,杭州(1 行受影响)
      

  6.   

    select * from table where Area Like '%你输入的值%'