View Single Post
Old 10-26-2021, 03:24 AM  
faperoni
Confirmed User
 
faperoni's Avatar
 
Industry Role:
Join Date: Feb 2015
Location: Amsterdam
Posts: 210
Maybe LIKE works better for you

Code:
SELECT * FROM Recipe WHERE Category LIKE '%seafood%' OR Category LIKE '%lunch%' ORDER BY RAND() LIMIT 5;");
if the keyword is always at the end of the string you can also use

Code:
SELECT * FROM Recipe WHERE Category LIKE '%seafood' OR Category LIKE '%lunch' ORDER BY RAND() LIMIT 5;");
Maybe its better to extract these keywords and put them in a separate table? LIKE (or REGEXP) are "slow".

More pattern matching examples and options:
https://dev.mysql.com/doc/refman/8.0...-matching.html
__________________
Faperoni.com Fucker.com
faperoni is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote