title: Update rows set uniqe values from another table MySQL
body: <p>I have two tables for example. First contains generated serials for details. The second contains produced datails. I need to insert unique serial numbers to the second.</p>
  <p><strong>T1</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">t1.ID</th>
  <th style="text-align: center;">t1.OBJ_TYPE</th>
  <th>t1.OBJ_SERIAL</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">5</td>
  <td>DRW157001</td>
  </tr>
  <tr>
  <td style="text-align: center;">2</td>
  <td style="text-align: center;">5</td>
  <td>DRW157002</td>
  </tr>
  <tr>
  <td style="text-align: center;">3</td>
  <td style="text-align: center;">5</td>
  <td>DRW157003</td>
  </tr>
  <tr>
  <td style="text-align: center;">4</td>
  <td style="text-align: center;">5</td>
  <td>DRW157004</td>
  </tr>
  <tr>
  <td style="text-align: center;">5</td>
  <td style="text-align: center;">5</td>
  <td>DRW157005</td>
  </tr>
  <tr>
  <td style="text-align: center;">6</td>
  <td style="text-align: center;">5</td>
  <td>DRW157006</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>T2</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">t2.ID</th>
  <th style="text-align: center;">t2.DETAIL_TYPE</th>
  <th>t2.DETAIL_SERIAL</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">5</td>
  <td>DRW157001</td>
  </tr>
  <tr>
  <td style="text-align: center;">2</td>
  <td style="text-align: center;">5</td>
  <td>DRW157005</td>
  </tr>
  <tr>
  <td style="text-align: center;">3</td>
  <td style="text-align: center;">5</td>
  <td><strong>NULL</strong></td>
  </tr>
  <tr>
  <td style="text-align: center;">4</td>
  <td style="text-align: center;">5</td>
  <td><strong>NULL</strong></td>
  </tr>
  <tr>
  <td style="text-align: center;">5</td>
  <td style="text-align: center;">5</td>
  <td><strong>NULL</strong></td>
  </tr>
  <tr>
  <td style="text-align: center;">6</td>
  <td style="text-align: center;">5</td>
  <td><strong>NULL</strong></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Is it possible to to make like this after update?</p>
  <p><strong>Result</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">t2.ID</th>
  <th style="text-align: center;">t2.DETAIL_TYPE</th>
  <th>t2.DETAIL_SERIAL</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">5</td>
  <td>DRW157001</td>
  </tr>
  <tr>
  <td style="text-align: center;">2</td>
  <td style="text-align: center;">5</td>
  <td>DRW157005</td>
  </tr>
  <tr>
  <td style="text-align: center;">3</td>
  <td style="text-align: center;">5</td>
  <td><strong>DRW157002</strong></td>
  </tr>
  <tr>
  <td style="text-align: center;">4</td>
  <td style="text-align: center;">5</td>
  <td><strong>DRW157003</strong></td>
  </tr>
  <tr>
  <td style="text-align: center;">5</td>
  <td style="text-align: center;">5</td>
  <td><strong>DRW157004</strong></td>
  </tr>
  <tr>
  <td style="text-align: center;">6</td>
  <td style="text-align: center;">5</td>
  <td><strong>DRW157006</strong></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>SQL query</p>
  <p><code>UPDATE t2, t1 SET t2.DETAIL_SERIAL = (SELECT t1.OBJ_SERIAL FROM t1 LIMIT 1 ) WHERE t1.OBJ_TYPE = t2.DETAIL_TYPE</code></p>