Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9058439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:43:25+00:00 2026-06-16T14:43:25+00:00

I have a table where I want to copy some data back to the

  • 0

I have a table where I want to copy some data back to the same table with two columns getting changed:

e.g:

TableMusic

titleid   musicid  tap_id            value

1234         1      3                 this is music
1324         1      3                 this is music test

I want the titleid and the value to be written back to the same table with musicid=3

Here the indexed columns are titleid, musicid

I have done the following script but got an error: attempt to insert duplicate key row in object ‘tablemusic’ with unique index ‘pk_tablemusic’

insert into tablemusic (titleid, musicid, value )
  select titleid, 3, value
  from tablemusic
  where musicid=1

What am I doing wrong here? Can someone come up with a clean script to get the job done.

following is an extract from my DB for one titleID:

titleid   musicid    tap_id              value

462847        1        3               this is my music value 
462847        2        1    
462847        3        1    
462847        4        1     

this is the same for all titleid’s. Now what I want to do is copy the value from musicid=1 to musicid=3 and also sometime change the tap_id to 3. I hope this is clear enough of what i want to achieve

Final Result want to achieve:

titleid musicid tap_id value

462847        1        3               
462847        2        1    
462847        3        3               this is my music value 
462847        4        1     
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:43:26+00:00Added an answer on June 16, 2026 at 2:43 pm

    The complexity is that some records exist so trying a simple insert duplicates the key and you get the error. What you have to do here is to break up the query into two prts

    1. Update the rows with musicid = 3 that exist
    2. Insert the rows where music id=3 does not exist
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to copy some rows data to another table, For example: I have
I have a table called _sample_table_delme_data_files which contains some duplicates. I want to copy
I Want to Copy some Data between two Data Bases, so I use an
I want to copy data of table into another but I have a pain
I have users table and want to SELECT some rows by bitmask criteria. I'll
I need to copy some data from one table to another in Oracle, while
I have been doing some data transformation/processing in PL/SQL and I want to eliminate
I want to have a database table that keeps data with revision history (like
I want to have another copy of some control upon dragging and dropping it
I need to copy some data from one table to another but I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.