title: MySQL : Insert Data With Single Query, But Auto Increment Number On Non-Auto Increment Column
body: <p>I have this SQL query :</p>
  
  <pre><code>INSERT INTO db1.outbox (DestinationNumber, TextDecoded)
  SELECT User.CellPhone, '$SMSMessage' as TextDecoded
  FROM db2.User
  WHERE User.PurchaseDate BETWEEN 2012-01-01 AND 2012-01-31
  </code></pre>
  
  <p>it does multiple rows insertion to 'outbox' table. and I can easily get the ID number of first row by using this query :</p>
  
  <pre><code>SELECT LAST_INSERT_ID()
  </code></pre>
  
  <p>and let's say I have 532 as result from <code>SELECT LAST_INSERT_ID()</code> and I have 34 rows inserted.</p>
  
  <p>how to use this 532 as initial number for other table named 'outbox_multipart' insertion and having it auto increment so the result will be like this :</p>
  
  <pre><code>+------+----------------+----------+----------------------------------+
  | ID   | phonenumber    | outboxID | message                          |
  +------+----------------+---------------------------------------------+
  |                      ......                                         |
  | 1025 | 555-123456     | 532      | part 2 : hello there!            |
  | 1026 | 555-999999     | 533      | part 2 : hello there!            |
  | 1027 | 555-888888     | 534      | part 2 : hello there!            |
  |                                                                     |
  |               ...... 34 rows inserted here .......                  |
  |                                                                     |
  +------+----------------+---------------------------------------------+ 
  </code></pre>
  
  <p>please note that outboxID column isn't auto increment column. but it must have auto increment number from 532 + 34 rows = 566.</p>