title: How to enforce 2 MySQL queries to run in series
body: <p>I need every day to get a list of all Customers past due and insert them into a new table, then i need to move the dates with one month, so they will be processed next month again.</p>
  
  <p>Currently i am running 2 SQL Queries in series</p>
  
  <pre><code>insert into history select * from customers where nextdate&lt;CURDATE()
  update customers set nextdate=calculation() where nextdate&lt;CURDATE()
  </code></pre>
  
  <p>But sometimes customers are updated, but not inserted into history.</p>
  
  <p>In think that the update begin to run before mysql finished the select.</p>
  
  <p>I am using Node js, he current method i am using for serialization, is that i am running the <code>update</code> in the callback from the <code>insert</code>, but probably the insert is called back before the code actually runs.</p>
  
  <p>It doesn't happen every time but i think that making a Stored procedure with both in it can help, anyone had some experience with it? </p>