Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Clone rows based on existing rows

Clone rows based on existing rows

Scheduled Pinned Locked Moved Database
databasecomtoolshelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ravi Bhavnani
    wrote on last edited by
    #1

    Can you SQL gurus help me craft an UPDATE statement that will insert a modified clone of a set of rows into a table? For example, my table FIELDS_IN_VIEW has 2 columns VIEW and FIELD and contains several thousand rows:

    Row VIEW FIELD


     1   23    100
     2   23    701
     4   23    459
    

    ...
    6500 99 804

    I'd like to clone all the rows that apply to view 23 for a new view (eg: 24). View 24 is guaranteed to not already exist in the table. Thanks, /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

    G 1 Reply Last reply
    0
    • R Ravi Bhavnani

      Can you SQL gurus help me craft an UPDATE statement that will insert a modified clone of a set of rows into a table? For example, my table FIELDS_IN_VIEW has 2 columns VIEW and FIELD and contains several thousand rows:

      Row VIEW FIELD


       1   23    100
       2   23    701
       4   23    459
      

      ...
      6500 99 804

      I'd like to clone all the rows that apply to view 23 for a new view (eg: 24). View 24 is guaranteed to not already exist in the table. Thanks, /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      G Offline
      G Offline
      goyal manish
      wrote on last edited by
      #2

      try it insert into FIELDS_IN_VIEW select 24, field from FIELDS_IN_VIEW where view = 23

      R 1 Reply Last reply
      0
      • G goyal manish

        try it insert into FIELDS_IN_VIEW select 24, field from FIELDS_IN_VIEW where view = 23

        R Offline
        R Offline
        Ravi Bhavnani
        wrote on last edited by
        #3

        Thanks, Manish! /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups