Insert into … values ( SELECT … FROM … )

前端 未结 26 2531
我在风中等你
我在风中等你 2020-11-21 05:40

I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle t

26条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-21 06:06

    Instead of VALUES part of INSERT query, just use SELECT query as below.

    INSERT INTO table1 ( column1 , 2, 3... )
    SELECT col1, 2, 3... FROM table2
    

提交回复
热议问题