儲存過程迴圈新增資料到資料庫中
阿新 • • 發佈:2019-02-19
CREATE DEFINER=`root`@`%` PROCEDURE `myproc`() BEGIN DECLARE num INT ; SET num = 1 ; WHILE num < 25 DO INSERT INTO product ( product_type_id, product_name, product_format, product_desc_price, product_price, product_picture, business_id, product_status, queue ) VALUES ( '1', '虎跑優質飲用水 19L', '19L*1/桶', '桶', '10.00', '/picture/water/2017052009.png', num, 'open', '6' ); INSERT INTO product ( product_type_id, product_name, product_format, product_desc_price, product_price, product_picture, business_id, product_status, queue ) VALUES ( '1', '千島湖飲用水 19L', '19L*1/桶', '桶', '10.00', '/picture/water/2017052010.png', num, 'open', '7' ); SET num = num + 1 ; END WHILE ; END