SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: copying some of recursive records

Hybrid View

  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,121
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    copying some of recursive records

    Code:
     data in myTable
    
    (ID) category area
    (1)      1    world 
    (2)      1    Asia 
    (3)      1    Europe 
    (4)      3    France 
    (5)      2    Japan 
    (6)      3    England  
    (7)      4    Paris  
    (8)      2    China 
    (9)      8    Beijing
    I have the above data in myTable.

    I like to copy a record and put it into another area.

    For example, let's suppose the object record for copying is "(2) Asia,"
    and target area is "(4) France."

    then,
    I can make a new record "(10) 4 Asia."
    This means the new record "Asia" is belongs to "France."
    The whole table will be like the following.

    Code:
     new data in myTable
    
    (ID) category area
    (1)      1    world 
    (2)      1    Asia 
    (3)      1    Europe 
    (4)      3    France 
    (5)      2    Japan 
    (6)      3    England  
    (7)      4    Paris  
    (8)      2    China 
    (9)      8    Beijing 
    (10)     4    Asia
    It's not difficult to make the new record.


    Now I am telling what I want.
    I like to copy not only the object record but also all records which are belongs to the object record.

    So my target table would be like the following.
    Code:
     target data in myTable
    
    (ID) category area
    (1)      1    world 
    (2)      1    Asia 
    (3)      1    Europe 
    (4)      3    France 
    (5)      2    Japan 
    (6)      3    England  
    (7)      4    Paris  
    (8)      2    China 
    (9)      8    Beijing 
    (10)     4    Asia
    (11)    10    Japan 
    (12)    10    China  
    (13)    12    Beijing  
    Thanks in advance

  2. #2
    Chessplayer kleineme's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I can't think of any way to do this with MySQL only. You would have to write a piece of code in the programming/scripting language if your choice.
    Never ascribe to malice,
    that which can be explained by incompetence.
    Your code should not look unmaintainable, just be that way.

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
  •