<tfoot id='wt0G3'></tfoot>

    <i id='wt0G3'><tr id='wt0G3'><dt id='wt0G3'><q id='wt0G3'><span id='wt0G3'><b id='wt0G3'><form id='wt0G3'><ins id='wt0G3'></ins><ul id='wt0G3'></ul><sub id='wt0G3'></sub></form><legend id='wt0G3'></legend><bdo id='wt0G3'><pre id='wt0G3'><center id='wt0G3'></center></pre></bdo></b><th id='wt0G3'></th></span></q></dt></tr></i><div id='wt0G3'><tfoot id='wt0G3'></tfoot><dl id='wt0G3'><fieldset id='wt0G3'></fieldset></dl></div>
    <legend id='wt0G3'><style id='wt0G3'><dir id='wt0G3'><q id='wt0G3'></q></dir></style></legend>
    • <bdo id='wt0G3'></bdo><ul id='wt0G3'></ul>
  1. <small id='wt0G3'></small><noframes id='wt0G3'>

      MySQL - 递归树结构

      时间:2023-10-09

        <i id='7CNLP'><tr id='7CNLP'><dt id='7CNLP'><q id='7CNLP'><span id='7CNLP'><b id='7CNLP'><form id='7CNLP'><ins id='7CNLP'></ins><ul id='7CNLP'></ul><sub id='7CNLP'></sub></form><legend id='7CNLP'></legend><bdo id='7CNLP'><pre id='7CNLP'><center id='7CNLP'></center></pre></bdo></b><th id='7CNLP'></th></span></q></dt></tr></i><div id='7CNLP'><tfoot id='7CNLP'></tfoot><dl id='7CNLP'><fieldset id='7CNLP'></fieldset></dl></div>

        <legend id='7CNLP'><style id='7CNLP'><dir id='7CNLP'><q id='7CNLP'></q></dir></style></legend>
      • <tfoot id='7CNLP'></tfoot>
          <bdo id='7CNLP'></bdo><ul id='7CNLP'></ul>

            • <small id='7CNLP'></small><noframes id='7CNLP'>

                  <tbody id='7CNLP'></tbody>
                本文介绍了MySQL - 递归树结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个将位置链接在一起的数据库表;一个位置可以在一个位置中,也可以在另一个位置内.

                I have a database table which link locations together; a location can be in a location, which can be inside another location.

                location (<id>, ....)
                location_parent (<location_id>, <parent_id>)
                

                这里是 MySQL/PHP 的深度:

                Here's the MySQL/PHP to go down for a depth of one:

                $sql = "SELECT id FROM se_locations_services WHERE parent_locationid IN
                ( SELECT location_id FROM se_locations_parent WHERE parent_id = '$locationid' )";
                

                在给定父位置的情况下,我如何仅使用 MySQL 获取其所有后代位置,无论多深?

                How do I, given a parent location, gets all its descendants locations, no matter how deep, just using MySQL?

                推荐答案

                有一个 好看的文章 概述了管理分层数据的各种方法.我认为它为您的问题提供了完整的解决方案,并展示了各种不太简单但速度更快的方法(例如嵌套集).

                There's a good-looking article over at mysql.com outlining various ways of managing hierarchical data. I think it provides a full solution to your question, and shows various less simple, but faster approaches (e.g. Nested Sets).

                这篇关于MySQL - 递归树结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:“无法建立数据库连接"背后的根本错误是什么?检查连接字符串、用户名和密码." 下一篇:如何递归查找孩子的所有ID?

                相关文章

                1. <small id='JaeaC'></small><noframes id='JaeaC'>

                  <i id='JaeaC'><tr id='JaeaC'><dt id='JaeaC'><q id='JaeaC'><span id='JaeaC'><b id='JaeaC'><form id='JaeaC'><ins id='JaeaC'></ins><ul id='JaeaC'></ul><sub id='JaeaC'></sub></form><legend id='JaeaC'></legend><bdo id='JaeaC'><pre id='JaeaC'><center id='JaeaC'></center></pre></bdo></b><th id='JaeaC'></th></span></q></dt></tr></i><div id='JaeaC'><tfoot id='JaeaC'></tfoot><dl id='JaeaC'><fieldset id='JaeaC'></fieldset></dl></div>
                  • <bdo id='JaeaC'></bdo><ul id='JaeaC'></ul>
                2. <tfoot id='JaeaC'></tfoot>

                    <legend id='JaeaC'><style id='JaeaC'><dir id='JaeaC'><q id='JaeaC'></q></dir></style></legend>