Skip to content

MATCH

MATCH(column1,column2,…) AGAINST (expression [search_modifier])

Section titled “MATCH(column1,column2,…) AGAINST (expression [search_modifier])”
  • match (column1,column2,…): Specifies the columns where the search is to be performed. The columns must be part of a FULLTEXT index. Multiple columns can be provided, separated by commas.
  • against (expression): Defines the string to search for within the columns specified in the MATCH function. The expression is usually a string that is enclosed in single or double quotes.
  • search_modifier: An optional parameter that determines the mode of the match. Possible values for the search modifier include IN NATURAL LANGUAGE MODE, IN BOOLEAN MODE, WITH QUERY EXPANSION, IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION, and IN BOOLEAN MODE WITH QUERY EXPANSION. Without a search_modifier, the query performs a natural language search.
SELECT *
FROM Employee
WHERE MATCH (name, position) AGAINST ('John Doe');
+----+-----------+----------------+
| ID | name | position |
+----+-----------+----------------+
| 1 | John Doe | Product Manager|
+----+-----------+----------------+

The MATCH statement in SQL is utilized for full-text searching. The specified MATCH (name, position) AGAINST ('John Doe') command matches rows in the Employee table where either the name or position column contains ‘John Doe’. The selected row is returned in the output.