Re: RE : SQL Syntax quickie

2003-11-12 Thread R. Joseph Newton
dan wrote: > The MAX(id) didn't return anything, Best check your data types, and syntax. Either ID is somehow a string value, or you are offering the wrong SQL syntax: mysql> describe test2; +-+-+--+-+-++ | Field | Type| Null | Key |

Re: RE : SQL Syntax quickie

2003-10-27 Thread Chuck Fox
Yet another solution SET ROWCOUNT 1 SELECT id FROM table ORDER BY id DESC Only works if there is an index on id and the RDBMS support backward scans Chuck [EMAIL PROTECTED] wrote: Another solution : For your query, try "SELECT MAX(id) FROM table" That works with mysql. -Message d'origine

RE: RE : SQL Syntax quickie

2003-10-27 Thread EUROSPACE SZARINDAR
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 À: [EMA

Re: RE : SQL Syntax quickie

2003-10-27 Thread dan
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

Re: RE : SQL Syntax quickie

2003-10-26 Thread dan
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 S

Re: RE : SQL Syntax quickie

2003-10-26 Thread Tore Aursand
On Sun, 26 Oct 2003 13:40:20 +, 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' ta

Re: RE : SQL Syntax quickie

2003-10-26 Thread Tore Aursand
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 b