How to correctly delete a string separated by commas (,) with a field arrchildid
I want to delete 1 of them and run mysql
UPDATE `category` SET `arrchildid`=replace(`arrchildid`,',1','') WHERE `catid`=100
As a result, I deleted all the items that should not be deleted. thank you very much for any good solutions.
PHPCMS uses this data structure, but I didn't find out how he handled it. When a category is deleted or modified, the arrchildid field of its parent category must be changed.
Reply to discussion (solution)
UPDATE `category` SET `arrchildid`=replace(concat(`arrchildid`,','), ',1,', '') WHERE `catid`=100
The value of arrchildid is 21,11, 1, 2
I want to delete 1 of them and run mysql
UPDATE `category` SET `arrchildid`=replace(`arrchildid`,',1','') WHERE `catid`=100
As a result, I deleted all the items that should not be deleted. thank you very much for any good solutions.
PHPCMS uses this data structure, but I didn't find out how he handled it. When a category is deleted or modified, the arrchildid field of its parent category must be changed.
An error occurred while running this statement in phpmyadmin. In addition, if the arrchildid value is 21,2, 11,1, it cannot be replaced. Is there a better solution?
The value of arrchildid is 21,11, 1, 2
I want to delete 1 of them and run mysql
UPDATE `category` SET `arrchildid`=replace(`arrchildid`,',1','') WHERE `catid`=100
As a result, I deleted all the items that should not be deleted. thank you very much for any good solutions.
PHPCMS uses this data structure, but I didn't find out how he handled it. When a category is deleted or modified, the arrchildid field of its parent category must be changed.
An error occurred while running this statement in phpmyadmin. In addition, if the arrchildid value is 21,2, 11,1, it cannot be replaced. Is there a better solution?
I don't know why. After I manually repeat it, the SQL will not go wrong.