I have written a query that updates a certain value in a comma separated list to some other value. I do know it is a very bad database design to have comma separated lists but in this case i don't have any other option.
so the query is
SELECT * FROM AppUser
WHERE AppValue LIKE '%429%' AND AppCode = 'BI' AND AppName = 'Categories'
UPDATE AppUser
SET AppValue = REPLACE(AppValue, '429', '506')
Now the query above does replace 429
with 506
, but what if there is already a 506
there. If I query it like that, it will result in duplication, and I will have two 506
like 405,506,565,506
instead of 405,506,565
.
So can you please guide me on how i would be able to avoid duplication?