problems with max()

admin

Administrator
Staff member
Hi I keep running into a problem when I try and get the max number in a auto increment field:

from the command line:

mysql> SELECT order_num FROM orders;

and a I get something similar to:
+---------------------+
|order_num |
+---------------------+
| 6 |
| 7 |
| 8 |
| 9 |
+---------------------+

so then I do my actual select with max:

mysql> SELECT MAX(order_num) FROM orders;

+-------------------------+
| max(order_num) |
+-------------------------+
| 0 |
+-------------------------+

I dont understand why it is giving me 0,

in PHP i tried :

$last_order_num = "SELECT order_num FROM orders";

$last_order_results = mysql_query($last_order_num, $connection) or die ("Couldnt get the god damn order numbers");

$order_num = max($last_order_results);

but this lso gave me 0,

what am i doing wrong it seems like one of those would work

thanks in advance

jake
 
Back
Top