层次数据查询 [英] hierarchi data query

查看:72
本文介绍了层次数据查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

employee_id manager_id名称
101空CEO
102101 GM
103102经理
104103软件工程师
105103软件工程师


在此数据结构中,我要创建上级员工ID 104的层次结构.


employee_id manager_id designation
101 NULL CEO
102 101 GM
103 102 MANAGER
104 103 SOFTWARE ENGINEER
105 103 SOFTWARE ENGINEER


In this data structure i want make a hierarchi of superior employee id 104


SELECT employee_id,manager_id,designation FROM manager
CONNECT by prior employee_id = 104


来连接

这是查询中使用的类似此错误的信息

消息156,第15级,状态1,第4行
关键字"by"附近的语法不正确.

帮助我解决这个问题....




This is the query what am used in this am getting the error like this

Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword ''by''.

help me to solve this....

推荐答案

请参阅这些文章
http://blogs.msdn.com/b/manisblog/archive/2007/08/17/sql-server-2008-hierarchyid.aspx [ SQL Server 2008中的HierarchyID数据类型 [ ^ ]
使用HierarchyID加载TreeView [
Please see these articles
http://blogs.msdn.com/b/manisblog/archive/2007/08/17/sql-server-2008-hierarchyid.aspx[^]
HierarchyID Data Type in SQL Server 2008[^]
Loading a TreeView using HierarchyID[^]
I think they may be helpful.


检查此网站
http://blogs.msdn. com/b/manisblog/archive/2007/08/28/sql-server-2008-hierarchyid-part-ii.aspx [
check this site
http://blogs.msdn.com/b/manisblog/archive/2007/08/28/sql-server-2008-hierarchyid-part-ii.aspx[^]


使用在SQL Server 2008中作为数据类型存在的hierarchyid.
use hierarchyid which is present as datatype in sql server 2008.


这篇关于层次数据查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆