• <legend id='3MzL2'><style id='3MzL2'><dir id='3MzL2'><q id='3MzL2'></q></dir></style></legend>
    • <bdo id='3MzL2'></bdo><ul id='3MzL2'></ul>
    1. <small id='3MzL2'></small><noframes id='3MzL2'>

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

      1. <tfoot id='3MzL2'></tfoot>

        带有关系 innoDB 的递归 MySQL 查询

        Recursive MySQL Query with relational innoDB(带有关系 innoDB 的递归 MySQL 查询)
        1. <small id='cUs3k'></small><noframes id='cUs3k'>

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

                1. 本文介绍了带有关系 innoDB 的递归 MySQL 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个类似(简化)的表结构:

                  I've got a table structure like (simplified):

                  内容

                   - id_content
                   - my_string1
                   - ...
                  

                  content_has_content

                  content_has_content

                    - id_content
                    - id_subcontent
                  

                  topic_has_content

                  topic_has_content

                    - id_topic
                    - id_content
                  

                  任何主题都可以有多个内容",任何内容"都可以有多个子内容"(内容实例).使用给定的 id_topic,我想从链接的内容、子内容、子内容的子内容等中接收所有 my_string1 的列表.

                  Any topic can have multiple 'content', any 'content' can have multiple 'subcontent' (instance of content). With a given id_topic I'd like to recieve a list of all my_string1 from the linked contents, subcontents, subcontents-of-subcontents, and so on.

                  我知道WITH"不适用于 mysql,但找不到合适的递归替代方案.

                  I understand "WITH" is not working for mysql but cannot find a nice recursive alternative.

                  谢谢丹尼尔

                  推荐答案

                  MySQL 中没有递归,而且你得到的结果是扁平的(没有结构).最好的方法仍然是在 PHP、Java 或您使用的任何编程语言中使用 while 循环.

                  There is no recursion in MySQL and also the result you would get would be flat (no structure). The best way is still a while loop in PHP, Java or whatever programming language you use.

                  查询可能如下所示:

                  SELECT C.*, CHC.ID_SUBCONTENT
                  FROM CONTENT C
                  LEFT OUTER JOIN CONTENT_HAS_CONTENT CHC ON CHC.ID_CONTENT = C.ID_CONTENT
                  WHERE C.ID = ?
                  ... // you get the idea
                  

                  并且在 PHP 中,您可以使用下一个 sub_content_id 重复查询,直到 ID_SUBCONTENT 为 null

                  and in PHP you could repeat the query with the next sub_content_id, until ID_SUBCONTENT is null

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

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)
                    <tbody id='yGJeo'></tbody>
                  <tfoot id='yGJeo'></tfoot>
                    <i id='yGJeo'><tr id='yGJeo'><dt id='yGJeo'><q id='yGJeo'><span id='yGJeo'><b id='yGJeo'><form id='yGJeo'><ins id='yGJeo'></ins><ul id='yGJeo'></ul><sub id='yGJeo'></sub></form><legend id='yGJeo'></legend><bdo id='yGJeo'><pre id='yGJeo'><center id='yGJeo'></center></pre></bdo></b><th id='yGJeo'></th></span></q></dt></tr></i><div id='yGJeo'><tfoot id='yGJeo'></tfoot><dl id='yGJeo'><fieldset id='yGJeo'></fieldset></dl></div>

                        <bdo id='yGJeo'></bdo><ul id='yGJeo'></ul>

                          • <legend id='yGJeo'><style id='yGJeo'><dir id='yGJeo'><q id='yGJeo'></q></dir></style></legend>

                            <small id='yGJeo'></small><noframes id='yGJeo'>