On Thu, May 08, 2003 at 03:12:45AM -0700, Nitin Nanivadekar wrote:
> 1. the max () keyword reports 'different' resultsets
> when following queries are sent to it,
> a. select max(id) from table1;
> b. select max(id) from table1 where id2=100;
> in any condition (like the low resources etc.) i
> should not get different results from seemingly
> identical queries.
As you've described it, it's certainly possible; it completely
depends on the table and it's contents.
> 2. i will also point one observation when i was
> hacking the max () function. when there is an empty
> set max() reports Null.
> this makes max() limited to
> arithmatic ops only.
I don't understand this assertion; MAX() works with strings as well.
If stray NULL values are scaring you, try:
select max(id) from mytable where id is not null;
Also consider using GREATEST().
> i am using max() to find the next
> incremental primary key index for some other table.
> i am now seriously considering NOT using max() for
> that reason after 1,. and 2. above.
Why would you have NULL values in your incremental primary key index
column? That (to me) implies a INT column, that should always have
> pls. comment.
Brian 'you Bastard' Reichert <reichert@stripped>
37 Crystal Ave. #303 Daytime number: (603) 434-6842
Derry NH 03038-1713 USA BSD admin/developer at large