
sql start with connect by prior SQL server 哪个版本支持 我用的是sql2008 看着貌似不支持start关键字 50
sqlstartwithconnectbypriorSQLserver哪个版本支持我用的是sql2008看着貌似不支持start关键字我要实现树查询也就是数据库递归查询不...
sql start with connect by prior SQL server 哪个版本支持 我用的是sql2008 看着貌似不支持start关键字 我要实现树查询 也就是 数据库递归查询 不使用这个方法 还可以用什么方法 进行递归查询 表中是根据ParentID建立联系的 原来的语句是这样的
select * from dbo.Depart
Start with [DepartID]=1 connect by prior DepartID = ParentID
提示错误为:
消息 336,级别 15,状态 1,第 2 行
'DepartID' 附近的语法不正确。如果它要用作公用表表达式,需要使用分号显式终止前一个语句。 展开
select * from dbo.Depart
Start with [DepartID]=1 connect by prior DepartID = ParentID
提示错误为:
消息 336,级别 15,状态 1,第 2 行
'DepartID' 附近的语法不正确。如果它要用作公用表表达式,需要使用分号显式终止前一个语句。 展开
1个回答
展开全部
用 with .. as实现递归。
withsubqry(id,name,pid) as(
select id,name,pid from test1 where id= 5 --start with
union all
select test1.id,test1.name,test1.pid from test1,subqry
where test1.pid = subqry.id --connect by
)
select* from subqry;
withsubqry(id,name,pid) as(
select id,name,pid from test1 where id= 5 --start with
union all
select test1.id,test1.name,test1.pid from test1,subqry
where test1.pid = subqry.id --connect by
)
select* from subqry;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询