I am running a website with classified ads and I'd like to set up a function which will send an email alert when a new ad matches some patterns.
The idea is to allow the users to store multiples patterns, then perform a SELECT with them:
select ad from table where (content LIKE '%this%' OR content LIKE '%that%')
Of course, I don't know in advance how many patterns the user will need.
One solution would be to create one line per user and per pattern, and selecting with joining the tables, but I am afraid of the database performance.
I've thought about JSON data but I can't figure out how to do something like that:
select ad from table where content like (["this","that"])
Or maybe there is a better way?
Edit
After viewing the first answers (thank you) I realize I was not clear enough.
The patterns will be also stored in the database, the final request should be something like:
select ad from table where content LIKE (select *something* from pattern_table where userId = 123)
The question is mainly : what is the best way to store the patterns in pattern_table
一旦尝试
select ad from table where content REGEXP 'this|that'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.