开发者

postgresql multiple insert with select query

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜