Thanks I'll try your suggestion about the LIMIT portion, that's what I want, to minimize the amount of data the program gets from the SQL server, making processing faster.
The program isn't a script as such that's executed from the web, it's a program that opens a socket, connects to IRC chat and acts as a network service. There's only ever one copy running, since it can't bind to the same socket on the same port more than once, it'll simply just die with a socket error. This program is always the one that accesses the database, and nothing else. So that I'm sure that nothing will happen between the INSERT and SELECT. I'll also give the mysql_insertid a go, that generally looks like what I want to happen, so that may be my best option all around. Many thanks for all of your help, Dan "Tore Aursand" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sun, 26 Oct 2003 13:40:20 +0000, dan wrote: > > The MAX(id) didn't return anything [...] > > Are you sure about that? Generally, MAX(id) _always_ returns something, > ie: > > SELECT MAX(user_id) FROM user > > This one will return the highest 'user_id' value, _or_ 0 if there are no > records in the 'user' table. > > > SELECT id FROM memodata ORDER BY id DESC > > Then you should also limit the expression, thus offloading the SQL server > a bit; > > SELECT id FROM memodata ORDER BY id DESC LIMIT 1 > > > then take the first line value and ignore the rest. > > With 'LIMIT' you don't need to worry about ignoring anything. Just ignore > ignoring. :-) > > > Ideally though i want the last line with the highest id number. > > If you want the last auto_increment value, you could always use the MySQL > proprietary 'mysql_insertid'; > > my $stInsert = $dbh->prepare( ... ); > $stInsert->execute(); > $stInsert->finish(); > my $last_insert_id = $stInsert->{ 'mysql_insertid' }; > > > I know for a fact that another INSERT won't happen before the SELECT > > because they happen immediately one after the other. > > Do yuo really? Is there _always_ only one user using the script? > > > -- > Tore Aursand <[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]