根据一个订单的ID 号.我要进行模糊查询
比如果想查订单号是以 1,3,5这三个数结尾的
我在文本框输入1,3,5 在以逗号拆分,然后在进行LIKE 相映模糊查询怎么查?如果只查以1结尾的容易,现在要查三个怎么弄?

解决方案 »

  1.   

    declare @tb table(id varchar(50))
    insert into @tb select '001'
    insert into @tb select '002'
    insert into @tb select '003'
    insert into @tb select '004'
    insert into @tb select '005'select * from @tb
    where charindex(','+right(id,1)+',',','+'1,3,5'+',')>0001
    003
    005string strid = "1,3,5";
    string sql="select * from tb where charindex(','+right(id,1)+',',','+"+strid+"+','";
      

  2.   

    根本不要拆分,直接查询就可以了:select * from 表名 where RIGHT(Convert(nvarchar(50),ID),1) in (1,3,5)