Hi Dan, To be sure to collect something, you could use the "nvl(VALUE_ORI, replacement_value_if_VALUE_ORI_is_null)" function which will return something if the entry value is null otherwise return the entry value.
select nvl( max(id), 0 ) from table_id ; The "nvl" is an Oracle function but sure that there is something similar on Mysql ================== SQL> create table table_id ( id integer ); Table created. SQL> select max(id) from table_id; MAX(ID) ---------- SQL> select nvl(max(id), 0) from table_id; NVL(MAX(ID),0) -------------- 0 SQL> insert into table_id(id) values (1); 1 row created. SQL> select nvl(max(id), 0) from table_id; NVL(MAX(ID),0) -------------- 1 ================== Michel -----Message d'origine----- De: dan [mailto:[EMAIL PROTECTED] Date: dimanche 26 octobre 2003 14:40 À: [EMAIL PROTECTED] Objet: Re: RE : SQL Syntax quickie The MAX(id) didn't return anything, i eventually settled for an idea posted to SELECT id FROM memodata ORDER BY id DESC then take the first line value and ignore the rest. Ideally though i want the last line with the highest id number. I know for a fact that another INSERT won't happen before the SELECT because they happen immediately one after the other. FYI, i'm using MySQL and DBD::mysql if that's any more help. Many thanks Dan "Tore Aursand" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sun, 26 Oct 2003 06:30:11 +0100, SIMON Cedric wrote: > > For your query, try "SELECT MAX(id) FROM table" > > That works with mysql. > > That should "work" with most databases, but what happens if there's a new > insert between the original insert and the SELECT statement above? > > This _could_ be solved by locking the table before the insert, and then > unlocking it again after you've select the maximum id from the same table. > > > -- > Tore Aursand <[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]