《MYSQL数据库mysql递归查询(分页版)代码》要点:
本文介绍了MYSQL数据库mysql递归查询(分页版)代码,希望对您有用。如果有疑问,可以联系我们。
MYSQL学习例子,mysql递归查询代码.
MYSQL学习call getPictureList('402880e63789b63a013789b646dc0000',1,5);
set max_sp_recursion_depth=12;
MYSQL学习CREATE PROCEDURE getPictureList (IN rootCategoryId varchar(32),IN m INT,IN n INT)
BEGIN
CREATE TEMPORARY TABLE IF NOT EXISTS tempCategoryList
(sno int primary key auto_increment,
category_id varchar(32),
depth int
);
DELETE FROM tempCategoryList;
CALL getCategoryList(rootCategoryId,0);
set @query=concat(
' select p.*',
' from tempCategoryList t,picture p,picture_category pc ',
' where t.category_id = pc.category_id and pc.pic_id = p.pid ',
' order by p.hot_value desc limit ',m,',',n);
select @query;
prepare stmt1 from @query;
execute stmt1;
deallocate prepare stmt1;
END;
CREATE PROCEDURE getCategoryList (IN rootCategoryId varchar(32),IN nDepth INT)
BEGIN
DECLARE done varchar(32) DEFAULT "";
DECLARE b varchar(32);
DECLARE cur1 CURSOR FOR SELECT category_id FROM category where parent=rootCategoryId;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
insert into tempCategoryList values (null,rootCategoryId,nDepth);
OPEN cur1;
FETCH cur1 INTO b;
WHILE done="" DO
CALL getCategoryList(b,nDepth+1);
FETCH cur1 INTO b;
END WHILE;
CLOSE cur1;
END;
MYSQL学习mysql递归查询替代函数实例
mysql递归查询树形叶子
Oracle递归查询树形结构
MySQL 递归查询当前节点子节点
mysql递归查询实现办法
Oracle递归查询SQL语句分享
sql递归查询代码(cte应用)
sql2005递归查询的例子
sql递归查询(with cte实现)
sql 递归查询的代码(图文)
sql server 递归查询数据
Oracle递归查询举例
欢迎参与《MYSQL数据库mysql递归查询(分页版)代码》讨论,分享您的想法,维易PHP学院为您提供专业教程。