In MySQL I am trying to copy a row with an autoincrement column ID=1 and insert the data into same table as a new row with column ID=2.
How can I do this in a single query?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Use
INSERT ... SELECT:where
c1, c2, ...are all the columns exceptid. If you want to explicitly insert with anidof 2 then include that in your INSERT column list and your SELECT:You’ll have to take care of a possible duplicate
idof 2 in the second case of course.