* Richard Brenner > I have a problem with a query: > > I use an application where users can post messages. The messages > are stored > in two tables that are related by the id of the new created message. I get > the last id with the following query: "select max(id) as maxid from > tasker_app"
Oops... that is the wrong way to do it. See below. > The forum has many users and sometimes it happens that there are multiple > inserts before I can receive the last id. > Is it possible to stop inserts until I have finished both inserts? It may be possible to stop inserts, but you don't have to. There is a special function just for this: LAST_INSERT_ID(). <URL: http://www.mysql.com/doc/en/Miscellaneous_functions.html > (halfway down the page) This function will return the last inserted id for _this_connection_, regardless of what have happened in any other simultaneous connections. -- Roger --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php