PHP MySQL Order By

ORDER BYKeywords are used to sort the data in the record set


Keywords used for sorting:

Keywords Description
asc Sort in ascending order, from small to large (default)
desc Descending order, from large to small

## Syntax example:

To learn more about SQL, please visit our SQL tutorial.


##Example

5.png


Result set limit

Example

8.png



Continuing Learning

About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!
Basic syntax select field from table order by field sort keyword Example select id,Age from Myguests order by Age desc; Example description Query the id and Age fields in the Myguests table and sort them in descending order In the following example, let us sort the field Age in the Myguests table in descending order
"; } ?>
Program running result:Just like the above example, If we don't want the data to be displayed too large, we can use limit.Sort the data in the Myguests table in ascending order and display only 5
"; } ?>
program running results:To learn more about SQL, please visit our SQL tutorial
||
"; } ?>
submit Reset Code
Category Detailed explanation