Insert into certain columns

This question already has an answer here:

  • Insert into … values ( SELECT … FROM … ) 21 answers

  • insert into table2
    (
        col2, col3, col4
    )
    select col1, col2, col3
    from table1
    

    You can combine select and insert in order to do this. This is how:

    insert into table2 (col2, col3, col4)
    select col1, col2, col3
    from table1
    

    你只需要在INSERT使用SELECT...FROM来选择你想要的列。

    INSERT INTO table2
    (
        column2, column3, column4
    )
    SELECT column1, column2, column3
    FROM table1
    
    链接地址: http://www.djcxy.com/p/94308.html

    上一篇: 在INSERT INTO内部选择

    下一篇: 插入某些列