title: MySQL select after insert
body: <p>Lets asume a table like:</p>
  
  <blockquote>
    <p>ID = INT, AutoIncrement</p>
    
    <p>VAR = VARCHAR, 65</p>
    
    <p>FOO = VARCHAR, 65</p>
  </blockquote>
  
  <p>I want to insert something new, and get the Auto-Generated ID, for further use.</p>
  
  <p>My current solution is:</p>
  
  <p>1.<code>INSERT into table (VAR,FOO) VALUES ('test','anothertest')</code></p>
  
  <p>2.<code>SELECT * FROM table ORDER BY ID LIMIT 1</code></p>
  
  <p>To get the last insert, but the problem is, what happends if the website lags, and there is a time gap between the queries?</p>
  
  <p>example:</p>
  
  <ol>
  <li><code>12:00AM 0.000s -&gt; "INSERT into table (VAR,FOO) VALUES ('test','anothertest')</code></li>
  <li><code>12:00AM 0.500s -&gt; "INSERT into table (VAR,FOO) VALUES ('xyz', '!!!!!</code>)`</li>
  <li><code>12:00AM 0.800s -&gt; "SELECT * FROM table ORDER BY ID LIMIT 1</code></li>
  </ol>
  
  <p>the Query in 3 would not return the ID from 1, it would return the ID from 2</p>
  
  <p>My Question no is, is there an absolute secure way to get a Value from a inserted Query? </p>
  
  <p>like a confirmation "test, anothertest has successfully inserted into table, ID is 20"</p>
  
  <p>the ID should be available as variable in php, just for information</p>