Share on Google+Share on Google+

php MySQL order by clause

In SQL generally we use three clauses, select ,from, and where.

php MySQL order by clause:


In SQL generally we use three clauses, select ,from, and where.  There are many more clauses are present in SQL which are used for different purpose. Order by is one of the important clause of SQL. Order by clause is used to sort a particular field in either ascending order or descending order.

General Format of SQL is as follows:

select <list of fields to be displayed or * for displaying all fields>

from <table name>

where <condition if any>

order by <field name> <asc-for ascending order, it is default order or desc-for descending order>



$db[email protected]_connect("localhost","root","");



die("Can not establish connection".mysql_error());



$result=mysql_query("select * from student order by name asc");



echo $row['age'];

echo" ".$row['name'];





28 rahul
28 shantanu
27 vikash
26 vinay



Posted on: December 17, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: php MySQL order by clause  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image