将 select 中的多行插入另一个 table
Insert multiple rows from select into another table
假设我有 `table1(col1,col2,col3),要在 col1 和 col3 上插入的值将相同,但要在 col2 上插入的值来自 select查询。
我如何编写我的查询以便我可以一次执行多次插入?
查询应该做什么的示例:
col1 | col2 | col3
1 val1 0
1 val2 0
1 val3 0
如果我没理解错的话,你会用insert . . .select
:
insert into table1(col1, col2, col3)
select 1, col2, 0
from <your other query here>;
假设我有 `table1(col1,col2,col3),要在 col1 和 col3 上插入的值将相同,但要在 col2 上插入的值来自 select查询。
我如何编写我的查询以便我可以一次执行多次插入? 查询应该做什么的示例:
col1 | col2 | col3
1 val1 0
1 val2 0
1 val3 0
如果我没理解错的话,你会用insert . . .select
:
insert into table1(col1, col2, col3)
select 1, col2, 0
from <your other query here>;