I have a table namely all_products
. In which tags are stored in the comma-separated form. Like tag1, tag2, tag3
. Now if the user updates the tag then I need to update the tag value in this set also. This table is used for caching purpose so can not normalize it. What I've done is
UPDATE all_products SET tags = replace(tags,
'Tag2', 'Tag2 Updated')
WHERE find_in_set('Tag2', tags)
The issue in the above query is if there are two tags namely tag2
and tag22
in the same row then the query will update both. I want it to update tag2
only.
Is there any way by which I can update the exact tag only?