条件是:大字符串是用一空格分开的,空格间的字符串若等于小字符串为真例如:
 '12'若含在大字符串'45 12 aa'中为真
  '12'若含在大字符串'123 de aa'中为假

解决方案 »

  1.   

    一种方法就是两边都加上空格,然后再用instr来比较。mysql> select instr(concat(' ','45 12 aa',' '),concat(' ','12',' '));
    +--------------------------------------------------------+
    | instr(concat(' ','45 12 aa',' '),concat(' ','12',' ')) |
    +--------------------------------------------------------+
    |                                                      4 |
    +--------------------------------------------------------+
    1 row in set (0.00 sec)mysql> select instr(concat(' ','123 de aa',' '),concat(' ','12',' '));
    +---------------------------------------------------------+
    | instr(concat(' ','123 de aa',' '),concat(' ','12',' ')) |
    +---------------------------------------------------------+
    |                                                       0 |
    +---------------------------------------------------------+
    1 row in set (0.00 sec)mysql>
      

  2.   

    select instr(concat(',',replace('45 123 aa',' ',','),','),concat(',',12,','))
    OR
    用正则
      

  3.   

    select find_in_set('12',replace('123 de aa',' ',','));
    先将空格替换成逗号,然后再用find_in_set函数即可,如果找不到返回0,找到返回在set中的位置(位置从1开始的)
      

  4.   

    [Quote = 3 楼 hitexam ]select find_in_set('12',replace('123 de aa',' ',','));
    先将空格替换成逗号,然后再用find_in_set函数即可,如果找不到返回0,找到返回在set中的位置(位置从1开始的)
    [/Quote]这个方法效率最好,一楼方法比这个效率上略差,二楼wwwwb的方法效率上就差得比较多了。