MySQL selecting the maximum value from a column
| From: | Melanie Gann | Date: | Tue, 05 Feb 2002 23:12:15 +0000 |
| Subject: | MySQL selecting the maximum value from a column | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-83649@lists.php.net to get a copy of this message | ||
Thank you all you listeners out there. I'll try to be respectful of your
time and patience, and apoligize in advance for my "greeness" - I am 2
weeks into PHP/MySQL.
I am trying to select the higest value from the column Thought_Num below.
But it returns nothing.
<?PHP
$db = mysql_connect("localhost", "root");
mysql_select_db("DynaSite",$db);
$result = mysql_query("SELECT MAX(Thought_Num) FROM quotes",$db);
$myrow = mysql_fetch_array($result);
print "the result is $myrow[Thought_Num]";
?>
If I change my select to something that without the MAX (e.g. Select from
quotes where DocID=1), the code works fine.
Thanks in advance for your help.
Regards,
Melanie
Second Street Web Design
http://www.second-street.com