Search code examples
mysqlsearchselectsql-likematch-against

How to search a word in MySQL table? MATCH AGAINST or LIKE?


I have a table for some companies that may have many branches in different countries. These countries are inserted in countries field.
Now, I have to make a searching system that allows users to find companies that have any branch in a specific country.
My question is: Which one do I have to use ? MATCH AGAINST or LIKE ? The query must search all records to find complete matched items.

  • attention: Records may have different country name separated with a comma.

Solution

  • MATCH AGAINST clause is used in Full Text Search.

    for this you need to create a full text index on search column countries.

    full text index search is much faster than LIKE '%country%' serach.