Skip to content
Advertisement

How to iteratively use INSERT INTO in PostgreSQL

I have Table1 with rows I want to iterate over, and insert values from those rows of data into another table.

So basically pseudo is:

Just looping through Table1, adding in one of its values every time.

Advertisement

Answer

I think you just want an INSERT INTO ... SELECT here:

Most SQL operations are inherently set based, meaning if you want to insert all records from one table into another, the operation would be viewed as a single thing.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement