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 
0

2 Answers 2

3

Try somethink like tis

INSERT INTO work_done ( id , col2 ... ) SELECT 20 , col2 ... FROM work_todo WHERE id = 10 
Sign up to request clarification or add additional context in comments.

5 Comments

Quite possibly, the values 10 and 20 are in fact numerical values and stored in a column of numerical type - so then they should not be put in double quotes in your query...
"20" is an identifier (e.g. a column name) in SQL. I doubt there is a column named "20" in the work table
answer updated :)
i just tested my query, this work well
oh, I have used quotation marks in brackets.. tx :)
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; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.