生成一张表,添加数据
DROP table IF EXISTS Dept;
create table Dept(ID int,ParentID int,msg varchar(20))
insert into Dept select 1,0,'中国'
insert into Dept select 2,1,'上海'
insert into Dept select 3,1,'浙江'
insert into Dept select 4,2,'普陀区'
insert into Dept select 5,

本文介绍了如何在SQL中使用递归函数和while循环进行数据查询。通过创建表并填充数据,展示了如何利用@@rowcount作为递归或循环条件,以实现多层数据的连续查询,直至找到没有连续id的情况。
最低0.47元/天 解锁文章
1263

被折叠的 条评论
为什么被折叠?



