user1487380
user1487380

Reputation: 362

PostgreSQL How to insert many record with one Insert statement

I have a table, that all other columns have the same values, only one difference, this column is result from another select statement.

I need somethings like

INSERT INTO my_table (orgid, status, userid )
    VALUES(12393, true, SELECT u.userid FROM user u)

I can use a loop statement with many insert statement inside, but i want something more easy, 1 sqlQuery and dont use of functions :-?

Upvotes: 1

Views: 160

Answers (1)

Iswanto San
Iswanto San

Reputation: 18569

Try this :

INSERT INTO my_table (orgid, status, userid )
SELECT 12393, true, u.userid FROM user u

Upvotes: 4

Related Questions