0

User inputs some keywords that he wants to get a notification, when a new post title contains these. Here is what I'm currently trying:

LOCATE( LOWER( REPLACE(  `app_notif_keywords` ,  ' ',  ',' ) ) , LOWER( REPLACE(  'Visiska tamsa | Pitch Black (2000)',  ' ',  ',' ) ) ) !=0

Here is a stripped down version:

LOCATE('the,gift,pitch,black', 'visiska,tamsa,|,pitch,black,(2000)')

However, I'm getting nothing returned. What can I use instead to make it work?

Bohemian
  • 412,405
  • 93
  • 575
  • 722
Gintas_
  • 4,940
  • 12
  • 44
  • 87

1 Answers1

1

To match any of a range of csv values, use regexp like this:

select * from mytable
where lower(concat(',', app_notif_keywords, ','))
  regexp lower(concat(',(', replace('Visiska tamsa Pitch Black', ' ', '|'), '),'))

See SQLFiddle

Bohemian
  • 412,405
  • 93
  • 575
  • 722