Example on how to do loop insert in mysql. This act like a function. NOTE that mysql does not support stored procedure.
DELIMITER $$
DROP PROCEDURE IF EXISTS insert_loop $$
CREATE PROCEDURE insert_loop ()
BEGIN
DECLARE i int DEFAULT 1;
WHILE i <=30 DO
UPDATE test_db.visitor_visit SET visitor_id=i WHERE id=i;
SET i = i + 1;
END WHILE;
END $$
CALL insert_loop();
Thanks for watching my blog. Do follow me on google+ or like my facebook page for more! :)
Obstrum Facebook Page
EmoticonEmoticon