How to insert into a table using loop based on another select statement

Viewed 3917

I have a select query which returns some IDs.

SELECT GROUP_ID FROM GROUP_REQUEST_MAPPING WHERE REQUEST_TYPE_ID = 1

As a result I get this.

GROUP_ID
6
7
8
9
14

I have to loop through the IDs and then insert that many rows in another table.

INSERT INTO REQ_TASK VALUES(_,_,_,IDs)

How do I do that. I am new to sql. Thanks

3 Answers
Related