Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Jim Hatfield
August 31, 2004, 9:22 pm
rate this thread
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.
Re: PHP/MySQL: using MIN() on an empty set of rows -> query error
A resource ID.
A return value FALSE indicates an error. Check mysql_error().
mysql_query() always returns a resource ID if the query was successful,
even if the result set is empty or contains NULL. What versions of PHP
and MySQL do you use?
In this case a result set with one value NULL would be correct (there's
no min-value in an empty set).