怎么查找英文中带"?"的字符串;
比如:我要查找一个table表中字段str的内容包含有"?"的所有记录出来,SQL如下:
select * from table where str regexp '?';
select * from table where str regexp '\?';
上面两条执行的结果均报错:
#1139 - Got error 'repetition-operator operand invalid' from regexp 
正确的写法怎么写呢????????

解决方案 »

  1.   

    SELECT * FROM bb WHERE mobile LIKE '%\?%'
      

  2.   


    select * from t where name REGEXP '[^\\?]*\\?\\.*';
      

  3.   

    select * from table where str regexp '\\?';
      

  4.   

    mysql> select 'adf?adf' regexp '\\?';
    +------------------------+
    | 'adf?adf' regexp '\\?' |
    +------------------------+
    |                      1 |
    +------------------------+
    1 row in set (0.00 sec)
      

  5.   

    select * from table where locate('?','str')>0;或select * from table where instr('str','?')>0;
      

  6.   

    select   *   from   table   where   locate( '? ', 'str ')> 0; 或 select   *   from   table   where   instr( 'str ', '? ')> 0;