I'm trying to check if my text contain any tag from my SQL table.
I created a function which changing my text to lowercase and remove everything what is not in [A-Za-z-0-9] for -
, example:
Hello! I want to rent my flat which is in the best district - Ealing.
and after using my PHP function:
hello-i-want-to-rent-my-flat-which-is-in-the-best-district-ealing
I have a SQL table:
| ID | PHRASE | TAGS |
| 1 | London | kings-cross,heathrow,camden-town,ealing |
| 2 | Berlin | charlottenburg-wilmersdorf,friedrichshain-kreuzberg |
And now - how I can check if my formated text (by my PHP function) contain PHRASE or any tag from TAGS column? I need a query, something like that:
SELECT * FROM `table` WHERE 'hello-i-want-to-rent-my-flat-which-is-in-the-best-district-ealing' LIKE CONCAT('%-',phrase,'-%') OR 'hello-i-want-to-rent-my-flat-which-is-in-the-best-district-ealing' LIKE CONCAT('%-',tags,'-%')
But I have more than one tag in TAGS column, so now I have to make a few SQL requests (if I have 3 tags, I need to explode this tags and make 3 SQL requests to check if text contain any tag). Is it possible to check it in one query?
Thanks.