Mysql programming: How to store multiple query results

Source: Internet
Author: User
Hello everyone, my requirement is as follows: When writing a mysql stored procedure, data in the cyclic cursor will continue to be queried based on the data # get the cursor value fetchroot_knowledge_cursor1__knowledge_id, _ knowledge_code; # Multiple records will be found here! What type of data can I use to store the results of these multiple records (_ childKids )? And traverse the result and store it in another table in sequence? This is my problem: selectknowledge_id1__childkidsfrom... mysql storage

Hello everyone, my requirements are as follows: When writing a mysql stored procedure,
When the data in the cyclic cursor is queried, the related records are queried based on the data.

# Start to get the cursor value
FETCH root_knowledge_cursor INTO _ knowledge_id, _ knowledge_code;
# Multiple records will be found here! What type of data can I use to store the results of these multiple records (_ childKids )? And traverse the result and store it in another table in sequence? This is my problem.
SELECT knowledge_id INTO _ childKids FROM edu_knowledge k
WHERE k.Knowledge_codeLike concat (_ knowledge_code, '% ');
IF _ childKids IS NOT NULL THEN
# Here we want to insert records to the table in sequence by repeating _ childKids.
Insert into a (rootKid, childKid) VALUES (_ knowledge_id, _ childKid );
# _ ChildKid is the value obtained when traversing _ childKids
End if;
UNTIL flag
End repeat;
CLOSE root_knowledge_cursor;

If you have any questions, please correct them!
If you don't have a C currency, you can't offer a reward. please forgive me!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.