MySQL comma-separated string how to correctly delete

Source: Internet
Author: User
There is a field arrchildid value of 21,11,1,2
I want to delete 1 of them and run MySQL
UPDATE ' category ' SET ' Arrchildid ' =replace (' arrchildid ', ', 1 ', ') WHERE ' catid ' =100

Results should not be deleted also deleted, there is any good solution, thank you very much
Phpcms used 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 is definitely to be changed.


Reply to discussion (solution)

UPDATE ' category ' SET ' Arrchildid ' =replace (concat (' Arrchildid ', ', '), ', 1, ', ') WHERE ' catid ' =100

There is a field arrchildid value of 21,11,1,2
I want to delete 1 of them and run MySQL

UPDATE ' category ' SET ' Arrchildid ' =replace (' arrchildid ', ', 1 ', ') WHERE ' catid ' =100

Results should not be deleted also deleted, there is any good solution, thank you very much
Phpcms used 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 is definitely to be changed.


I ran the statement in phpMyAdmin and there was a better workaround if the Arrchildid value was 21,2,11,1 and could not be replaced.

There is a field arrchildid value of 21,11,1,2
I want to delete 1 of them and run MySQL

UPDATE ' category ' SET ' Arrchildid ' =replace (' arrchildid ', ', 1 ', ') WHERE ' catid ' =100

Results should not be deleted also deleted, there is any good solution, thank you very much
Phpcms used 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 is definitely to be changed.


I ran the statement in phpMyAdmin and there was a better workaround if the Arrchildid value was 21,2,11,1 and could not be replaced.

Do not know what is the reason, manually hit the SQL will not be wrong

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.