List:General Discussion« Previous MessageNext Message »
From:Brian Reichert Date:May 8 2003 3:55pm
Subject:Re: A seroius trouble with MySQL
View as plain text  
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;

See <http://www.mysql.com/doc/en/Problems_with_NULL.html>

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
a value.

> pls. comment.
> -nitin

-- 
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	
Thread
A seroius trouble with MySQLNitin Nanivadekar8 May
  • Re: A seroius trouble with MySQLBrian Reichert8 May
    • Re: A seroius trouble with MySQLCurtis Maurand12 May
  • Re: A seroius trouble with MySQLDan Nelson8 May
  • Re: A seroius trouble with MySQLKeith C. Ivey8 May
  • re: A seroius trouble with MySQLEgor Egorov10 May