Search code examples
mysqlsql-like

mysql like with all permutation of words


Helo to all

for example I have row with this filed name : "Happy cow milk";

if I search for "Happy milk" with using "%Happy%milk%" it works, now I want to get this result with this query : "milk Happy" or "milk cow"...

how to I do it ? thanks in advance .


Solution

  • https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html solve the problem !

    SELECT * FROM table_name WHERE MATCH(col1, col2)
    AGAINST('search terms' IN NATURAL LANGUAGE MODE)