Home > Database > Mysql Tutorial > mysql编程,如何存储多个查询结果

mysql编程,如何存储多个查询结果

WBOY
Release: 2016-06-06 09:41:15
Original
1354 people have browsed it

mysql存储

大家好,我的需求是这样的,在写mysql存储过程的时候,
在循环游标中的数据时,根据数据会继续查询相关记录

#开始获取游标的值
FETCH root_knowledge_cursor INTO _knowledge_id,_knowledge_code;
#此处查到的记录会是多条!我可以采用什么样的数据类型来存储这多条记录的结果(_childKids)?并将该结果进行遍历,依次存储到另一张表中?这就是我的问题
SELECT knowledge_id INTO _childKids FROM edu_knowledge k
WHERE k.knowledge_code LIKE CONCAT(_knowledge_code,'%');
IF _childKids IS NOT NULL THEN
#此处希望可以循环 _childKids ,依次向表插入记录
INSERT INTO a(rootKid,childKid) VALUES (_knowledge_id,_childKid);
#_childKid为遍历_childKids 时取得的值
END IF;
UNTIL flag
END REPEAT;
CLOSE root_knowledge_cursor;

如果有表达不清楚的地方,还请大家指正!
没有C币悬赏不了,还请见谅!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template