PHPMySQLOrderBy, phpmysqlorderby_PHP tutorial

Source: Internet
Author: User
PHPMySQLOrderBy and phpmysqlorderby. The PHPMySQLOrderBy and phpmysqlorderbyORDERBY keywords are used to sort the data in the record set. The ORDERBY keyword ORDERBY is used to sort the data in the record set. PHP MySQL Order By, phpmysqlorderby

The order by keyword is used to sort the data in the record set.

Order by keyword

The order by keyword is used to sort the data in the record set.

The order by keyword sorts records in ascending order by default.

If you want to sort data in descending order, use the DESC keyword.

Syntax

SELECT column_name(s)FROM table_nameORDER BY column_name(s) ASC|DESC

Instance

The following example selects all the data stored in the "Persons" table and sorts the results according to the "Age" column:

 ";}mysqli_close($con);?>

The above results will be output:

Glenn Quagmire 33Peter Griffin 35

Sort by two columns

You can sort multiple columns. When sorting by multiple columns, the second column is used only when the values of the first column are the same:

SELECT column_name(s)FROM table_nameORDER BY column1, column2

Related reading:

Php programming notes sharing-very practical

The http://www.bkjia.com/PHPjc/1130668.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1130668.htmlTechArticlePHP MySQL Order By, phpmysqlorderby order by keywords are used to sort the data in the record set. The order by keyword 'Order by' is used to sort the data in the record set ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.