On 31-Aug-2001 Greg Callaghan wrote: > Hi, > > I have tables in which I use the mysql "AutoIncrement" facility to generate > a new ID when creating new rows. > > What I typically do is to (a) create a new row and then (b) retrieve the > associated ID directly after this by using the "SELECT ID FROM TABLE_NAME > WHERE ID IS NULL" method. > Huh ? Where'd that come from ? > Should I really be putting some sort of locking around this to avoid > obtaining the wrong ID value in high load situations??? No. it belongs to the connection and won't change. > If so what locking > method is recommended?? (a sample code excert would be nice). None. $qry="insert into order (dtime,cust,add1,add2 ...) now(), $custnum, '$add1', '$add2' ..."; SQLQuery($qry); $qry="insert into orderline (ordid, line, partno, qty) select LAST_INSERT_ID(), line, partno, qty from tmptbl"; SQLQuery($qry); -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. (53kr33t w0rdz: sql table query) --------------------------------------------------------------------- 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