Level 39
It's only sql
insert into tb (d1,d2) select d1,d2 from ta;
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi. I am new to mysql but i have previous experience in oracle. I want to loop a selection and then insert the data into another table. Is there any way to do it in mysql? As per my research i found that i could loop using a variable but everytime i have to select inside the loop to get what i want. I want to achieve something like this in mysql:
DELIMITER //
CREATE PROCEDURE insert_data()
BEGIN
for REC in (select data_1, data_2 from table_a)
loop
insert into table_b
values(rec.data_1,rec.data_2);
end loop;
END
DELIMITER ;
Please or to participate in this conversation.