源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

SQLserver2008使用表达式递归查询

  • 时间:2021-11-07 10:17 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:SQLserver2008使用表达式递归查询
[u]复制代码[/u] 代码如下:
--由父项递归下级 with cte(id,parentid,text) as (--父项 select id,parentid,text from treeview where parentid = 450 union all --递归结果集中的下级 select t.id,t.parentid,t.text from treeview as t inner join cte as c on t.parentid = c.id ) select id,parentid,text from cte --------------------- --由子级递归父项 with cte(id,parentid,text) as (--下级父项 select id,parentid,text from treeview where id = 450 union all --递归结果集中的父项 select t.id,t.parentid,t.text from treeview as t inner join cte as c on t.id = c.parentid ) select id,parentid,text from cte
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部