PHP/MySQL: using MIN() on an empty set of rows -> query error

From: Jim Hatfield (jim.hatfield_at_insignia.com)
Date: 08/31/04


Date: Tue, 31 Aug 2004 16:22:26 +0100

I'm using: "select min(objid) from table_name where objid > $objid"
to select the next row in a sequence where there may be gaps. It
works fine unless the where clause results in an empty set.

>From the command line, a value is *always* returned, which is NULL
when the set of rows selected by the where clause is empty. I wasn't
sure what I expected mysql_query to return. I didn't expect a FALSE
result, since the query is syntactically valid, but that's what I got.

Surely this is a bug? An empty result set would seem to be the correct
response, not a query error.

jim

-- 
Jim Hatfield