--由父项递归下级

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

最新文章

  1. linux 添加 service 服务并自动添加 chkconfig 启动级别
  2. 解决 connect to host github.com port 22 operation timed out
  3. ajax和json对象
  4. ASP.NET 5 (vNext) 理解和概述
  5. 安卓第十三天笔记-服务(Service)
  6. UVALive 6093 Emergency Room --优先队列实现的模拟
  7. Wall---hdu1348(求凸包周长 模板)
  8. 从原理上搞定编码-- Base64编码
  9. Web开发——Http协议剖析
  10. 如何计算ModBus超时时间?
  11. HDU 1080 Human Gene Functions--DP--(变形最长公共子)
  12. restful restAPI 的定义方式
  13. WebSocketSharp 的使用
  14. mysql数据库的查询,添加,删除,还原,备份
  15. PostgreSQL分页
  16. [转] 前后端分手大师——MVVM 模式
  17. SQLite 知识摘要 --- 事务
  18. Navicat Premium
  19. C++“隐藏实现,开放接口”的实现方案
  20. Applese的回文串-dfs

热门文章

  1. contain与compareDocumentPosition
  2. Django QuerySet API
  3. Arcgis Javascript API 开发笔记
  4. tcp连接的建立与释放
  5. segment fault本质
  6. kolla all-in-one 安装
  7. 关于angularJS的$watch的 一些小用法
  8. html5适应屏幕的方案
  9. windows平台下安装Beautiful Soup
  10. Prism开发人员指南5-WPF开发 Developer's Guide to Microsoft Prism Library 5.0 for WPF (英汉对照版)