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 6858831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:12:31+00:00 2026-05-27T02:12:31+00:00

Can we simply duplicate an entry in the database based on it’s ID without

  • 0

Can we simply duplicate an entry in the database based on it’s ID without having to mention all the field names for that row to be duplicated.

I have a row that looks like

id name last city state whatever
1  joe  doe  xyz  NY    yyy

I would like to make a duplicate. id is auto increment. What is the easiest way to do this.

  • 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-05-27T02:12:32+00:00Added an answer on May 27, 2026 at 2:12 am

    Based on your comment on @Adam Wenger’s answer, I would just read all fields in one query and then build a new query skipping the id field.

    Something like:

    SELECT * FROM table_name WHERE id=some_id
    

    php:

    $sql = "INSERT INTO table_name SET ";
    $first = true;
    foreach ($row as $key => $value)
    {
      if ($key != 'id')
      {
         if ($first) 
         {
            $first = false;
         }
         else
         {
           $sql .= ", ";
         }
         $sql .= '`' . $key . "`='" . $value . "'";
      }
    }
    // run query
    

    By the way, I would generate a prepared statement in PDO for both queries so that I would not have to worry about escaping the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hate generating an exception for things that I can simply test with an
When you declare a type parameter for the class, you can simply use that
Can I simply use if(myString == nil) For some reason a string that I
Possible Duplicate: WHY an Anonymous class in Java can't implement multiple interfaces directly? Simply
I have a bunch of nodes that I wish to duplicate and simply change
Possible Duplicate: Is there memset() that accepts integers larger than char? As it can
Possible Duplicate: Ioc/DI - Why do I have to reference all layers/assemblies in entry
According to this site I can simply write $user = getlogin(); but the group
I'm trying to make an applet which I can simply drag an image. And
Can you simply delete the directory from your python installation, or are there any

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.