HAMMAD ALI
HAMMAD ALI

Reputation: 175

How to insert column of other table in postgresql

I want to insert a column of other table and one parameter of this table have a hard coded value. I want to iterate this value with the each return value of other table column. How can i do this with insert query?

let 3,4,6 is the return column value of other table.

insert into table(value1,value2)
values (2,select id from table2)

Return column

2       3
2       4
2       6

Upvotes: 0

Views: 69

Answers (1)

user330315
user330315

Reputation:

Get rid of the values clause:

insert into table(value1,value2)
select 2, id 
from table2

Upvotes: 4

Related Questions