Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql find keywords in text

I have a Mysql InnoDB table with 10k keywords and I want to match them against several texts.

Some keywords have several words and I only want exact matchs.

Example: Keywords - brown fox, lazy cat, dog, fox, rabbit

Text - The quick brown fox jumps over the lazy dog

I want the query to return - brown fox, dog, fox

like image 823
Hugo Gameiro Avatar asked Dec 01 '25 04:12

Hugo Gameiro


1 Answers

SELECT * FROM tenKTable 
WHERE 'The quick brown fox jumps over the lazy dog' LIKE CONCAT('%',keyword,'%')

Source: MySQL SELECT query string matching

like image 191
istos Avatar answered Dec 02 '25 20:12

istos