title: MySQL INSERT and SELECT LAST_INSERT_ID() in one line
body: <p>I was wondering if there was a way to change this statement</p>
  
  <pre><code>INSERT INTO [table] VALUES ([values]);
  SET @last_id = LAST_INSERT_ID();
  </code></pre>
  
  <p>Into a single line. Something such as</p>
  
  <pre><code>SELECT 
  CASE WHEN ( SELECT COUNT(id) FROM [table] WHERE id=1 ) &gt; 0 
  THEN 'false' 
  WHEN ( INSERT INTO [table] VALUES ([values]) )
  THEN LAST_INSERT_ID()
  END INTO @myid;
  </code></pre>
  
  <p>(which could effectively be written in a single line)</p>
  
  <p>Would the <code>WHEN ( INSERT INTO ...)</code> statement is attempted, will it return a value that we can check?</p>
  
  <p>Will it also execute the <code>INSERT</code> even if it is within a <code>CASE</code> statement?</p>