1

I want to copy one row from one table to another table. But in the process I want change value of id. For example to 20. How to do it?

I have this code

INSERT INTO work_done
SELECT * FROM work_todo
WHERE id = 10
Martin54
  • 1,349
  • 2
  • 13
  • 34

2 Answers2

3

Try somethink like tis

INSERT INTO work_done
          ( id
          , col2
           ...
          )
     SELECT 20
          , col2
           ...
      FROM work_todo WHERE id = 10
Léo R.
  • 2,620
  • 1
  • 10
  • 22
0
select *
 into work_done
 from work_todo
where id = 10;

update work_done a
   set a.id = 20;

OR

 select case id
            when id = 10
              then id = 20
     into work_done
     from work_todo
    where id = 10;
Random_User
  • 363
  • 1
  • 7