There is a table with a tag column that has different tags separated by a , like below:
| id | tag |
| -- | ----- |
| 1 | a,b,c |
| 2 | b,a,h |
| 3 | c,g,e |
How can I select every rows that has for example a and b in their tag column.
I am using REGEX in MySQL, the problem is when the position of tags changes (ie: a,b and b,a), I cannot get all rows with the desired tags.
Here is the query to get both a and b tags:
SELECT * FROM sample_table WHERE tag REGEXP 'b.*a'
I am seeking for a regex that is indifferent to the position of the tags.