例如 TABLE_A 有记录id    value
-------------
1    abcde
2    abcd
3    abc执行:select id from TABLE_A where some_function(value,'abcdef');
返回:id 为 1 的记录。match 函数由于有诸多限制,所以不符合我的需求,请问有没有some_function这样的函数呢?请教了!

解决方案 »

  1.   

    select id from TABLE_A where locate('abcdef',value)>0;
    or
    select id from TABLE_A where  value like 'abcdef';
      

  2.   

    如果你匹配要求很高可以考虑 regexp 正则表达~
      

  3.   

    select id from TABLE_A 
    where INSTR('abcdef', value)
    order by LENGTH(REPLACE('abcdef', value, ''))
    limit 1
      

  4.   

    当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
    http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
    http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html8、如何给分和结贴?
    http://community.csdn.net/Help/HelpCenter.htm#结帖
      

  5.   

    用REPLACE将匹配字符替换为空,再取长度,如果要匹配的字符串与字段VALUE中的字符顺序一致
    select id from TABLE_A where INSTR('abcdef',value)
    order by LENGTH(REPLACE('abcdef',value,'')) limit 1