When I use the MAX() (Aggregate) Function in MySQL, I get one recordset even when I know it should be zero. Why does this happen? This is scary, because I usually count the rows, and if they're more than zero or equal to one, etc., I do something with that results. I haven't tested any other Aggregates, but imagine this isn't the only one.
Examples (in PHP):
Using the MAX() function...
Code: Select all
$query = "e;SELECT MAX(Age) AS MaxAge FROM people WHERE Age > 99999"e;;
$result = mysql_query($query, $connection) or die(mysql_error());
echo mysql_num_rows($result).' records returned';If I remove the MAX() function...
Code: Select all
$query = "e;SELECT Age FROM people WHERE Age > 99999"e;;
$result = mysql_query($query, $connection) or die(mysql_error());
echo mysql_num_rows($result).' records returned';