Copy data from one table to another and change id

This question already has an answer here:

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

  • 尝试像这样的思想

    INSERT INTO work_done
              ( id
              , col2
               ...
              )
         SELECT 20
              , col2
               ...
          FROM work_todo WHERE id = 10
    

    select *
     into work_done
     from work_todo
    where id = 10;
    
    update work_done a
       set a.id = 20;
    

    要么

     select case id
                when id = 10
                  then id = 20
         into work_done
         from work_todo
        where id = 10;
    
    链接地址: http://www.djcxy.com/p/94316.html

    上一篇: PHP MySQL PDO INSERT然后SELECT

    下一篇: 将数据从一个表复制到另一个表并更改ID