title: SQL Copy row in a table with relations
body: <p>Hope some one can help me, I would like to copy rows in same table and that table has relation  to another table that I have to copy related row accordingly:</p>
  
  <p><strong>Table1</strong></p>
  
  <pre><code>       table1Id table0Id otherColumn 
            1         3        8
            2         3        9
            3         4        6
  </code></pre>
  
  <p>I copied rows with table0Id = 3 </p>
  
  <p><strong>Table1</strong></p>
  
  <pre><code>       table1Id table0Id otherColumn 
            1         3        8
            2         3        9
            3         4        6
          -------------------------
            4         3        8
            5         3        9
  </code></pre>
  
  <p>I would like to do the same to Table2 depending to the Table1 Ids like this:</p>
  
  <p><strong>Table2</strong> </p>
  
  <pre><code>       table2Id table1Id otherColomn
             1        1        0
             2        2        5
             3        3        8
  </code></pre>
  
  <p><strong>Table2</strong> </p>
  
  <pre><code>       table2Id table1Id otherColomn
             1        1        0
             2        2        5
             3        3        8
           -----------------------
             4        4 new Id 0
             5        5 new Id 5
  </code></pre>
  
  <p>As you see row 1 and 2 are copied in table2 but they have new Ids from newly added rows in table1.
  I know how to do the firs part but I'm stuck at the second part.</p>