There is a table of the type:

id | category 1 | 1,2,3,4 

How to add a category value to a cell to 5 , if there are values 2 and 3 in this cell itself, for example?

My request is not capable.

  UPDATE post SET category=CONCAT(category,', 5') WHERE id = 1 AND category = 2 AND category = 3 

Thank you

  • Such tables as you better not do. For the reason that you described and the request, which made up. For these purposes, a table is made with a many-to-many relationship. But if you don't want to do it right, then try UPDATE post SET category=CONCAT(category,', 5') WHERE id = 1 AND category LIKE '%2%' AND category LIKE '%3%'; - ArchDemon

0