Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
MySQL 不支持分层查询,因此您无法使用简单的 SELECT 来完成此操作。您可以尝试使用存储函数模拟分层查询,可以在此处找到如何执行此操作的示例:http://explainextended.com/2009/03/17/hierarchical-queries-in-mysql/。
或者,您可以在 PHP 中使用递归使用多个查询来完成此操作:
function print_row_and_children($row, $level = 0) { out_ident($level); out_row($row); foreach (get_children($row) as $child) { print_row_and_children($child, $level + 1); } }
MySQL doesn't support hierarchical queries, so you can't do this with a simple SELECT. You can try emulating the hierarchical query with a stored function, example how to do this can be found here: http://explainextended.com/2009/03/17/hierarchical-queries-in-mysql/.
Alternatively, you can do this using multiple queries, in PHP, using recursion:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
MySQL 不支持分层查询,因此您无法使用简单的 SELECT 来完成此操作。您可以尝试使用存储函数模拟分层查询,可以在此处找到如何执行此操作的示例:http://explainextended.com/2009/03/17/hierarchical-queries-in-mysql/。
或者,您可以在 PHP 中使用递归使用多个查询来完成此操作:
MySQL doesn't support hierarchical queries, so you can't do this with a simple SELECT. You can try emulating the hierarchical query with a stored function, example how to do this can be found here: http://explainextended.com/2009/03/17/hierarchical-queries-in-mysql/.
Alternatively, you can do this using multiple queries, in PHP, using recursion: