I am trying to fetch all the data from the database with a certain content tags value. If I run the code below, it only returns the row with id 1, even though the word tag is part of the tags value in both rows. I also added %or% operator but it is fetching the exact row. When I search for tag it is showing 2 rows, but using the value in $mytags below, it match es only 1 row.
I want the expression to get a row if anything in $mytags matches.
SQL
$mytags = "tag, tag1";
SELECT * FROM table WHERE tags LIKE '%$mytags%' ORDER BY id DESC
| id | body | tags |
|---|---|---|
| 1 | Loreum Content 1 | tag, tag1 |
| 2 | Loreum Content 2 | tag |