帮忙写一个通过父节点ID查询所有子节点ID的SQL
时间:2011-06-07
来源:互联网
create table t_dept
(
n_dept_id int(11) not null auto_increment,
n_keyin_id int(11) not null,
n_dept_supervisor_id int(11) not null,
n_dept_contact_id int(11),
n_dept_father_id int(11),
vc_dept_name varchar(4000) not null,
vc_dept_tel varchar(4000),
vc_note varchar(8000),
dt_del_time datetime,
primary key (n_dept_id)
);
其中:n_dept_id自己的ID, n_dept_father_id父ID。
有木有mysql大神帮我写一个一个通过自己的ID查询所有子节点ID的SQL。我参考了http://www.cnblogs.com/fromchaos/archive/2010/12/15/1907031.html,但是一直第一句话就报错,不知道原因。
(
n_dept_id int(11) not null auto_increment,
n_keyin_id int(11) not null,
n_dept_supervisor_id int(11) not null,
n_dept_contact_id int(11),
n_dept_father_id int(11),
vc_dept_name varchar(4000) not null,
vc_dept_tel varchar(4000),
vc_note varchar(8000),
dt_del_time datetime,
primary key (n_dept_id)
);
其中:n_dept_id自己的ID, n_dept_father_id父ID。
有木有mysql大神帮我写一个一个通过自己的ID查询所有子节点ID的SQL。我参考了http://www.cnblogs.com/fromchaos/archive/2010/12/15/1907031.html,但是一直第一句话就报错,不知道原因。
作者: chongchongyehenmao 发布时间: 2011-06-07
参考下贴中的多种方法。
http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/02/4142971.aspx
MySQL中进行树状所有子节点的查询
http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/02/4142971.aspx
MySQL中进行树状所有子节点的查询
作者: ACMAIN_CHM 发布时间: 2011-06-07
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28