MySQL: Tree-Hierarchical query
- Uninteresting
- Misleading
- Offensive
- Repetitive
- Other

SUB-TREE WITHIN A TREE in MySQLIn my MYSQL Query to Create Table:
I have inserted a set of tuples (Query):
The inserted rows has following Tree-Hierarchical-Relationship:
I written a query to find relationship:
And output is:
[QUESTION] Instead of complete Hierarchical Tree, I need a
Please help me on this. If not query, a stored-procedure can be helpful. I tried, but all efforts were useless! |
|||||||||||||||||||||
migrated from stackoverflow.com Dec 8 '12 at 9:42This question came from our site for professional and enthusiast programmers. |
|||||||||||||||||||||
|
|||||||||||||||||||||
|
I already addressed something of this nature using Stored Procedures : Find highest level of a hierarchical field: with vs without CTEs (Oct 24, 2011) If you look in my post, you could use the GetAncestry and GetFamilyTree functions as a model for traversing the tree from any given point. UPDATE 2012-12-11 12:11 EDTI looked back at my code from my post. I wrote up the Stored Function for you:
It actually works. Here is a sample:
There is only one catch. I added one extra row for the owner
Here is the data
|
|||||||||
|
- Uninteresting
- Misleading
- Offensive
- Repetitive
- Other

|
What you are using is called Adjacency List Model. It has a lot of limitations. You'll be problem when you want to delete/insert a node at a specific place. Its better you use Nested Set Model. There is a detailed explanation. Unfortunately the article on mysql.com is does not exist any more. |
|||||||||
|
protected by RolandoMySQLDBA Dec 11 '12 at 18:38
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
MySQL: Tree-Hierarchical query的更多相关文章
- Mysql错误:Ignoring query to other database解决方法
Mysql错误:Ignoring query to other database解决方法 今天登陆mysql show databases出现Ignoring query to other datab ...
- mysql中slow query log慢日志查询分析
在mysql中slow query log是一个非常重要的功能,我们可以开启mysql的slow query log功能,这样就可以分析每条sql执行的状态与性能从而进行优化了. 一.慢查询日志 配置 ...
- Error NO.2013 Lost connection to Mysql server during query
系统:[root@hank-yoon ~]# cat /etc/redhat-release CentOS release 6.3 (Final) DB版本:mysql> select @@ve ...
- MySQL查询过程中出现lost connection to mysql server during query 的解决办法
window7 64位系统,MySQL5.7 问题:在使用shell进行数据表更新操作的过程,输入以下查询语句: ,; 被查询的表记录数达到500W条,在查询过程中出现如题目所示的问题,提示" ...
- MySQL5.1升级5.6后,执行grant出错:ERROR 2013 (HY000): Lost connection to MySQL server during query【转载】
转载: MySQL5.5升级5.6后,执行grant出错:ERROR 2013 (HY000): Lost connection to -mysql教程-数据库-壹聚教程网http://www.111 ...
- Procedure execution failed 2013 - Lost connection to MySQL server during query
1 错误描述 Procedure execution failed 2013 - Lost connection to MySQL server during query 2 错误原因 由错误描述可知 ...
- MySQL中查询时"Lost connection to MySQL server during query"报错的解决方案
一.问题描述: mysql数据库查询时,遇到下面的报错信息: 二.原因分析: dw_user 表数据量比较大,直接查询速度慢,容易"卡死",导致数据库自动连接超时.... 三.解决 ...
- Lost connection to MySQL server during query,MySQL设置session,global变量及网络IO与索引
Navicat导出百万级数据时,报错:2013 - Lost connection to MySQL server during query 网上一番搜索,修改mysql如下几处配置文件即可: sel ...
- 解决Lost connection to MySQL server during query错误方法
昨天使用Navicat for MySQL导入MySQL数据库的时候,出现了一个严重的错误,Lost connection to MySQL server during query,字面意思就是在查询 ...
- mysqldump导出报错"mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `file_storage` at row: 29"
今天mysql备份的crontab自动运行的时候,出现了报警,报警内容如下 mysqldump: Error 2013: Lost connection to MySQL server during ...
随机推荐
- Java Socket Server的演进 (一)
最近在看一些网络服务器的设计, 本文就从起源的角度介绍一下现代网络服务器处理并发连接的思路, 例子就用java提供的API. 1.单线程同步阻塞式服务器及操作系统API 此种是最简单的socket服务 ...
- IOS Animation-贝塞尔曲线与Layer简单篇(一)
IOS Animation-贝塞尔曲线与Layer简单篇 swift篇 1.介绍 贝塞尔曲线: 贝塞尔曲线是计算机图形图像造型的基本工具,是图形造型运用得最多的基本线条之一.它通过控制曲线上的四个点( ...
- Flex小结
参考两篇文章 文章1 文章2 容器用display: flex;或display: inline-flex;指定为弹性Flex布局.采用Flex布局的元素,称为Flex容器(flex containe ...
- NSDate NSString相互转化
时间戳是经常用到的,今天就总结一下 //设置转化格式 NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter s ...
- CSS的样式表基本概念
一.样式表分类 1.内联样式表 <p style="fint-size:24px;">直接在标签内部进行样式设置</style> 2.内嵌样式表 <h ...
- Atitit 编程语言知识点tech tree v2 attilax大总结
Atitit 编程语言知识点tech tree v2 attilax大总结 大分类中分类小分类知识点原理与规范具体实现(javac#里面的实现phpjsdsl(自己实现其他语言实现 类与对象实现对象实 ...
- scrollview 中嵌套多个listview的最好解决办法
在scrollview中嵌套多个listview的显示问题. 只需要调用如下的方法传入listview和adapter数据即可. /** * 动态设置ListView组建的高度 */ public s ...
- 实现步骤: 推送&传感器&UIDynamic
一.本地通知基本使用: #01.请求授权(8.0以前默人授权) #02.创建本地通知 #03.设置通知内容 #04.设置通知时间(多久后发通知) #05.发送通知 二.本地通知而外设置: #01.设置 ...
- ssh(sturts2_spring_hibernate) 框架搭建之hibernate1
一.hibernate简单了解: ⑴.hibernate一个java领域里面的一个持久化的ORM框架. 持久化:就是对对象的数据修改,hibernate会把修改的数据同步到数据库中. ORM:Obje ...
- Entity Framework 5中应用表值函数进行Linq查询
Entity Framework 5引入了表值函数(Table-Valued Functions TVFs).表值函数的返回类型是一个Table类型,可用在SQL查询语句中.最简单的表值函数,读取客户 ...
