Ask the pre-sort traversal tree algorithm (non-recursive infinite-pole classification algorithm), delete a branch node and all of its child nodes related issues

Source: Internet
Author: User
Ask the pre-sort traversal tree algorithm (non-recursive infinite-pole classification algorithm) to delete a branch node and all of its child nodes



Delete a branch node and all of its child nodes, see a piece of code from the Internet, and find this to be wrong,
Please ask, how to write SQL, thank you!
------to solve the idea----------------------
Delete from food where lft>= current node lft and RGT <= current node RGT

------to solve the idea----------------------
UPDATE nested_category SET lft = lft-@myWidth WHERE lft > @myRight
should be for
UPDATE nested_category SET lft = lft-@myWidth WHERE lft > @myLeft
  • 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.