0

I have a table with three columns:

id, 
name:string, 
location:int

I need to copy all records with location = 14 to the same table, but I need the copies to change locations to 15. Of course, id's must be changed too, to their autoincrement values.

How do I do that in PostgreSQL?

3
  • 1
    u want to update location 14 to 15 ??u can use update query Commented Jun 24, 2014 at 12:41
  • @GaneshP No he can't just update because he needs new ids Commented Jun 24, 2014 at 12:46
  • No, I need to copy them, leaving original records intact. Commented Jun 24, 2014 at 13:07

1 Answer 1

3
insert into t (name, location)
select name, 15
from t
where location = 14
Sign up to request clarification or add additional context in comments.

1 Comment

I don't need to delete it, I need to copy them, leaving original records intact.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.