Maybe you have autocommit on or something weird? From the MySQL documentation ( version 5.5), LAST_INSERT_ID() is per-connection, so it should be valid for each of your clients.