Discussion board
How do I find second highest value from a table?
By Abhijit Paul
Hi sir,

how to find the second highest value from a table....
Reply
Post   Reset
Teacher SiliconIndia replied to Abhijit Paul Friday, November 27, 2009
Hi abhijit,

If you want to find the second highest value from a table, then simply order by the field you are interested in and take the second row, like this:

<?php

$query = mysql_query("SELECT number FROM table ORDER BY number DESC LIMIT 2");
$second_highest = mysql_result($query,1,0);
echo "the answer to your question is $second_highest";
?>