MATCH ( ) AGAINST( )

This MySQL function is used only for columns indexed by a FULLTEXT index, and only in WHERE clauses.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

MATCH(column[, ...]) AGAINST (string)

Explanation

This function is used only for columns indexed by a FULLTEXT index, and only in WHERE clauses. In these clauses, it can be a condition used to search columns for a given string. Text in the string containing spaces is parsed into separate words, so a column matches if it contains at least one word. Small words (3 characters or less) are ignored.

Examples

SELECT applicant_id
FROM applications
WHERE MATCH (essay) AGAINST ('English');

This SQL statement searches the table containing data on people applying for admission to the college. The essay column contains a copy of the applicant's admission essay. The column is searched for applicants who mention the word English so that a list of applicants that have voiced an interest in the English program will be displayed.