mysql match against multiple words

前端 未结 2 1728
醉酒成梦
醉酒成梦 2021-01-01 19:41

Below is an example sql I am stuck with, it will not return a product named \"iphone 4s\", It returns 10 other result. Any help would be great thanks

1st sql exampl

相关标签:
2条回答
  • 2021-01-01 20:32

    Use REGEXP

    SELECT * FROM products 
    WHERE desc REGEXP 'iphone[[. .]]*4s'
    LIMIT 10;
    

    SQLFiddle demo

    0 讨论(0)
  • 2021-01-01 20:36

    To match an exact phrase, just use double quotes to surround the phrase to match;

    SELECT * 
    FROM products 
    WHERE MATCH(desc) 
          AGAINST('"iphone 4s"' IN BOOLEAN MODE) 
    LIMIT 10
    

    More info at the manual pages.

    0 讨论(0)
提交回复
热议问题