How can I write SelectQuery for SELECT LAST_INSERT_ID()?
Although the original query has no table name, db_select() would expect the table name.
The following works perfectly assuming the insert operation took place in another hook and the last insert id is not available into my hook:

$query = db_select('mytable');
$query-&gt;addExpression('LAST_INSERT_ID()', 'last_id');

$result = $query-&gt;execute()-&gt;fetch();
print $query;
echo '&lt;br&gt;';
echo 'Insert ID: '.$result-&gt;last_id;


Query output:

SELECT LAST_INSERT_ID() AS last_id FROM {mytable} mytable