So I have some CSV values stored in a mySQL database.
For example:
ID Name parentID
1 Dave 1,4,6
2 Josh 2
3 Pete 10
4 Andy 2,10
Using this query
SELECT * FROM `table` WHERE `parentID` LIKE %4%
Only Dave will be returned, this is correct. However if I select using: LIKE %1%, pete and andy are selected as well as dave, because they conatin '1'.
I need the query to be able to distinguish '10' for example, from '1'. It needs acknowledge each value between a comma is distinct and appreciate the fact the last comma may be omitted.
Am I right in thinking perhaps REGEX could do the job instead?
Thanks.