Insert into … values ( SELECT … FROM … )

前端 未结 26 2534
我在风中等你
我在风中等你 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:03

    To get only one value in a multi value INSERT from another table I did the following in SQLite3:

    INSERT INTO column_1 ( val_1, val_from_other_table ) 
    VALUES('val_1', (SELECT  val_2 FROM table_2 WHERE val_2 = something))
    

提交回复
热议问题