例:
nickname,address
123456   [厂商发货!](厂商送货)江苏省苏州市吴江市松陵镇东牛角
怎么这这个含有方括号的语句

解决方案 »

  1.   

    SELECT * FROM TB WHERE address LIKE '%[[]%' AND address LIKE '%[]]%'
      

  2.   

     where name like '%[[]%'
      

  3.   

    select * form tb where address like '%[%' ESCAPE '[' 
      

  4.   


    --> 测试数据: [tb]
    if object_id('[tb]') is not null drop table [tb]
    create table [tb] (nickname int,address varchar(51))
    insert into [tb]
    select 123456,'[厂商发货!](厂商送货)江苏省苏州市吴江市松陵镇东牛角' union all
    select 12345,'[厂商发货!(厂商送货)江苏省苏州市吴江市松陵镇东牛角' union all
    select 1234,'厂商发货!](厂商送货)江苏省苏州市吴江市松陵镇东牛角'--开始查询
    select * from [tb] where [address] like '%/[%/]%' ESCAPE '/'--结束查询
    drop table [tb]/*
    nickname    address
    ----------- ---------------------------------------------------
    123456      [厂商发货!](厂商送货)江苏省苏州市吴江市松陵镇东牛角(1 行受影响)