drop Procedure IF EXISTS Test;
Create Procedure Test ()
the begin
DECLARE I int; # declare variables
declare count int; # declare variables
set i = 0; # variable assignment
set count = (select count (* ) from app_device); # variable assignments
while i <count do # loop end condition: out while loop when i is greater than COUNT
the INSERT app_device_contact` the INTO `(` serial_number`, `tel`) the VALUES (
(SELECT serial_number from app_device Order by DEVICE_ID limit ASC i,. 1), '. 3');
SET I = I +. 1; # cycle time, i plus one
end while;
select * from app_device_contact; # View test data in Table
End
Call test ();
mysql insert data by way of sub-queries
Guess you like
Origin www.cnblogs.com/saorui/p/12049191.html
Recommended
Ranking