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 ....