It's occured to me that in the instance of running an insert query, it's always going to be on the master server (unless you're inserting into slaves, not advisable). Which means the lifespan of the program (if web based) is going to be limited to the connection you've created to the master. So, only the master is going to give you the last_insert_id . You could change sql connection mid program run, but why would you want to?