title: MySQL: LAST_INSERT_ID() returns 0
body: <p>I've got this test table: </p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE IF NOT EXISTS `test` (
      `id` INT(10) AUTO_INCREMENT,
      PRIMARY KEY (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=4;
  </code></pre>
  
  <p>inserting using either of these three</p>
  
  <pre class="lang-sql prettyprint-override"><code>INSERT INTO `test` (`id`) VALUES (NULL);
  INSERT INTO `test` (`id`) VALUES (0);
  INSERT INTO `test` () VALUES ();
  </code></pre>
  
  <p>and issuing </p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT LAST_INSERT_ID();
  </code></pre>
  
  <p>but the query always results in <code>0</code>.</p>
  
  <p>PHP's <code>mysql_insert_id</code> and <code>PDO::lastInsertId()</code> yield no result either.</p>
  
  <p>I've been toying with this whole day and can't get it to work. Ideas?</p>