开发者

postgresql multiple insert with select query

开发者 https://www.devze.com 2023-01-01 11:23 出处:网络
i need to perform a insert query for multiple rows whereby the first column is anumeric and identi开发者_如何学JAVAcal value and the second values are queried from another table.

i need to perform a insert query for multiple rows whereby the first column is a numeric and identi开发者_如何学JAVAcal value and the second values are queried from another table.

something like

insert into table (33, select col2 from another_table);

can this be accomplished with a single statement?


like this

insert into table 
select 33, col2 from another_table;


If you want to specify columns in your insert query, you should use this syntax:

INSERT INTO table (id, col2_name) (SELECT 33, col2 FROM another_table);
0

精彩评论

暂无评论...
验证码 换一张
取 消