Home > Database > Mysql Tutorial > body text

Detailed explanation of how MySQL implements the method of creating stored procedures and adding records in a loop

黄舟
Release: 2017-05-28 09:44:09
Original
1431 people have browsed it

This article mainly introduces the method of MySQL to create stored procedures and loopadd records, involving basic mysql stored procedure creation and calling related operations For tips, friends who need them can refer to

. The example in this article describes the method of creating a stored procedure and adding records in a loop in MySQL. Share it with everyone for your reference, the details are as follows:

Create first, then call:

-- 创建存储过程
DELIMITER;//
create procedure myproc()
begin
declare num int;
set num=1;
while num <= 24 do
insert into t_calendar_hour(hourlist) values(num);
set num=num+1;
end while;
commit;
end;//
-- 调用存储过程
CALL myproc();
Copy after login

The above is the detailed content of Detailed explanation of how MySQL implements the method of creating stored procedures and adding records in a loop. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!