title: How can I reset an MySQL AutoIncrement using a MAX value from another table?
body: <p>I know this won't work. I tried it in various forms and failed all times. What is the simplest way to achieve the following result?</p>
  <pre><code>ALTER TABLE XYZ AUTO_INCREMENT = (select max(ID) from ABC);
  </code></pre>
  <p>This is great for automation projects.</p>
  <pre><code>SELECT @max := (max(ID)+1) from ABC;        -&gt; This works!
  select ID from ABC where ID = (@max-1);     -&gt; This works!
  ALTER TABLE XYZ AUTO_INCREMENT = (@max+1);  -&gt; This fails :( Why?
  </code></pre>