This table has a text column that stores references to other records in CSV format, for example:
+----+----------------+ | id | linked_folders | +----+----------------+ | 90 | NULL | | 91 | NULL | | 92 | 123,1,4,40 | | 93 | 123,1 | | 94 | NULL | | 95 | 235,8 | | 96 | 90 | | 97 | NULL | | 98 | NULL | | 99 | NULL | +----+----------------+ $id = 90; SELECT * FROM my_table WHERE id = $id OR $id is in linked_folders
The above pseudo query should return rows 90 and 96.
I want to match if a certain exact value I have is on this field.
I'm thinking using LIKE might not work because I don't know if the comma exists before or after it.
Do I have any alternatives?
Can be achieved using
FIND_IN_SET
:Demo here