SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Repeating a row in a table

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Beside the historic creek in Kingston, London
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Repeating a row in a table

    I want to duplicate a row in a table.

    I thought that

    UPDATE table1 SET id '1' = id '2';
    might do it, but it doesn't. Help, please, experts ...

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    690
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    I don't understand what you are trying to accomplish. Give some sample data that describes the contents before and after the operation.

  3. #3
    SQL Consultant silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,470
    Mentioned
    35 Post(s)
    Tagged
    1 Thread(s)
    Code:
    INSERT
      INTO table1
         ( id
         , somecol )
    SELECT 5
         , somecol
      FROM table1
     WHERE id = 4
    does your table have id as the primary key?
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Beside the historic creek in Kingston, London
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, r937, you helped enormously elsewhere. I would have been back sooner, only there weren't any email notices.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •