Dear sir ,
I would like to know how to get the highest number as display.Fpr example a set of ages are in the database.I need only the highest age as output
Dear sir ,
I would like to know how to get the highest number as display.Fpr example a set of ages are in the database.I need only the highest age as output
select age from table1 order by age desc limit 1
What this does, piece by piece:
select age from table1 : Basic query, will get the age for every entry in table1
order by age: Sorts the results by age. Lowest is first by default
desc : Changes the sort order to descending. This will make the results sorted with the highest age first
limit 1: Will only return the first result after the sort.
Note that you can then use this result to easily retrieve all entries that share that highest age using it as a subquery:
select * from table1 where age = (select age from table1 order by age desc limit 1)
Use the max aggregate function...
Select max(age) from table1
All times are GMT -7. The time now is 01:51 PM. |