I have a table which has a column with numbers (no specific order).
What would be the shortest way to insert the minimal number in this column into $min
variable in PHP ?
I have a table which has a column with numbers (no specific order).
What would be the shortest way to insert the minimal number in this column into $min
variable in PHP ?
list($min) = mysql_fetch_row(mysql_query('SELECT IFNULL(MIN(column), 0) FROM table'));
If you want something else than 0
returned when there are no rows, just edit the 2nd parameter of IFNULL
. If there are guaranteed to be at least 1 row, or you want NULL when there are no rows, you can remove the IFNULL
completely.