Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get highest integer value from mysql table PHP

Tags:

php

mysql

how to get highest integer value from mysql table PHP

   $getingstoredata=mysql_query('select number from number ');

   while ($getstd=mysql_fetch_row($getingstoredata)){

   print_r($getstd);
                                                    }

and table stricture is same like this image http://fastcoding.tk/table.png

i want to display highest integer value for example it 120 is highest value in this table

like image 706
Virat21 Avatar asked Aug 04 '26 23:08

Virat21


2 Answers

use MAX()

SELECT MAX(number) FROM number
like image 125
rray Avatar answered Aug 06 '26 14:08

rray


You can simply use the Aggregate Functions. SELECT MAX(field_name) FROM table_name GROUP BY field_name;

You can also use "order by" clause with DESC and fetch the first row from result-set.

like image 24
Prafulkr Avatar answered Aug 06 '26 14:08

Prafulkr