Chaitanya Lakshmi
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook

How do I find second highest value from a table?

4/10/2012

1 Comment

 
<?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"; 
?> 
1 Comment
Venkat
5/15/2012 07:42:53 pm

i think we can do like this also.

(SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees))

Reply



Leave a Reply.

    Archives

    April 2012
    March 2012
    February 2012

    Categor

    All
    Ajax
    Api
    Cross Site Scripting
    Css
    Curl
    Design Patterns
    Drupal
    Exception Handling
    Htaccess
    Html
    Javascript
    Jquery
    Json
    Linux
    Mysql
    Oops
    Php
    Regular Expressions
    Web 2.0
    Webservices
    Wordpress
    Xhtml

    RSS Feed

Powered by Create your own unique website with customizable templates.