MySQL: how to return the maximum value of a field from a table?

The simplest example, if possible, give.

Answer 1, authority 100%

$row = mysql_fetch_object(mysql_query("select max(`field`) as `myname_of_var` from `table`"));

In general, use frameworks

Answer 2, authority 50%

  MAX ()  -


Answer 3, authority 50%

select max(`field`) from `table`


$db=new PDO($dsn, $user, $password);
$req=$db->prepare("select max(`field`) from `table`");
echo '$max=',$max;

Leave a reply

Please enter your comment!
Please enter your name here