PHP MySQL Aggregate MIN
From w3cyberlearnings
Contents |
PHP MySQL Aggregate Function MIN()
The Aggregate Function MIN() returns the smallest value in the row.
Syntax
SELECT MIN(salary) FROM employee_salary;
Example 1
<?php define('HOST', 'localhost'); define('USER', 'root'); define('PASS', 'yeething'); define('DBNAME', 'woowood'); $connection = mysql_connect(HOST, USER, PASS) or die("can not connect to the server!<br/>"); $rdb = mysql_select_db(DBNAME) or die("The " . DBNAME . "database could not be selected"); $sel_query = "SELECT MIN(salary) FROM employee_salary"; $result = mysql_query($sel_query, $connection) or die(mysql_error($connection)); echo mysql_result($result, 0); mysql_close($connection); ?>
Output
20