Need help with PHP and MySQL

I have a table in which there is a column with numbers (there is no specific order).

What would be the shortest way to insert the minimum number in this column into the $min variable in PHP?

+4
source share
2 answers
 list($min) = mysql_fetch_row(mysql_query('SELECT IFNULL(MIN(column), 0) FROM table')); 

If you want to return something else besides 0 when there are no rows, just edit the second IFNULL parameter. If you are guaranteed to be at least 1 line, or you want NULL when there are no lines, you can completely remove IFNULL .

+7
source
 SELECT MIN(column) FROM 'table' 
0
source

All Articles