Mysql finds keywords in text

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

Some keywords contain a few words, and I need only exact matches.

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

Text - Fast brown fox jumps over a lazy dog.

I want the query returned - brown fox, dog, fox

+3
source share
2 answers
SELECT * FROM tenKTable WHERE 'The quick brown fox jumps over the lazy dog' LIKE CONCAT('%',keyword,'%') 

Source: MySQL SELECT query string matching

+4
source

Here is one idea:

 SELECT keyword FROM Keywords JOIN (SELECT 'The quick brown fox jumps over the lazy dog' as col) k on k.col like Concat('%',keywords.keyword,'%') 

And SQL Fiddle .

Good luck.

+1
source

All Articles