SQLSERVER的递归
2024-09-21 00:50:25
实际项目如遇到按照如地区这样树状结构的条件递归查询数据的场景中,可以使用。
CREATE FUNCTION [dbo].[GetAllChildrenTypeById]
(
@id varchar(50)
)
RETURNS TABLE AS RETURN
with cte as
(
SELECT [id]
,[dictionaryTypeCode]
,[text]
,[parentId]
,[sort]
,[availabl]
,[leaf]
,[url]
,[value] FROM [Dictionary] where ID = @id
union all
SELECT a.[id],a.[dictionaryTypeCode],a.[text],a.[parentId],a.[sort],a.[availabl],a.[leaf],a.[url],a.[value] FROM [Dictionary] a join cte b on a.[parentId] = b.Id
)
select id from cte GO
最新文章
- 八款常见的Android游戏引擎
- The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder is not applicable for the arguments
- beta版本贡献率
- linux grep和正则表达式
- VS2010在网络共享目录使用IntelliSense、ipch、sdf和SQL Compact Server相关问题
- 修改nagios密码和遇到的问题
- [bzoj4098] [Usaco2015 Open]Palindromic Paths
- java Properties类使用基础
- Oracle安装、Navicat for Oracle、JDBCl连接、获取表结构
- CountDownLatch、CyclicBarrier、Semaphore共同之处与区别以及各自使用场景
- SIOCGMIIPHY 和 SIOCSMIIREG 命令
- jsp 错误处理
- koa中间件机制详解
- dubbo控制器xml文件报错
- [转]xml解析工具的效率比较QDomDocument、TinyXml-2、RapidXml、PugiXml
- (转)JDK安装配置教程
- noip第2课作业
- .net 图片上传
- 【Java-Web】初始化加载Serlvet工程后-HttpServlet报错
- 面经:Google两轮背靠背
热门文章
- java 数字左补齐0
- Codeforces Round #554 (Div. 2) C. Neko does Maths(数学+GCD)
- 我的python中级班学习之路(全程笔记第一模块) (第一章)(第2部分:如何设置python中的字体颜色,猜年龄练习题解答,while else语句,pycharm的使用)
- MySql的Communications link failure解决办法
- Kindle复活记
- 贪吃蛇游戏——C语言双向链表实现
- rabbitmq - (消息队列) 的基本原理介绍
- Houdini Distributed Simulations and Render
- Sql语句基础练习(一)
- Go语言--数组、切片、