SQL: INSERT INTO…VALUES..SELECT

后端 未结 4 1243
一向
一向 2021-01-01 13:23

How do i write INSERT statement if i get the values of colA from TableX, colB from TableY and colC from TableZ?

eg: INSERT INTO TableA (colA, colB, colC) VALUES (?,?

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 13:56

    Insert into TableA (ColA, ColB, ColC) . . .
    

    Must be the column names as the are in Table A. There's nothing wrong with

    Insert into TableA (ColA, ColB, ColC) . . .
    Select TableX.Col1, TableY.Col1, TableZ.Col5 
    From TableX, TableY, TableZ
    Where . . . 
    

提交回复
热议问题