Science, Tech, Math › Computer Science Ordering MySQL Data Request data in ascending or descending order with ORDER BY Share Flipboard Email Print Ezra Bailey / Getty Images Computer Science PHP Programming Tutorials MySQL Commands Perl Python Java Programming Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Angela Bradley Angela Bradley Computer Science Expert B.A, History, Eastern Oregon University Angela Bradley is a web designer and programming expert with over 15 years of experience. An expert in iOS software design and development, she specializes in building technical hybrid platforms. Learn about our Editorial Process Updated on March 29, 2019 When you query a MySQL database, you can sort the results by any field in an ascending or descending order just by adding ORDER BY at the end of your query. You use ORDER BY field_name ASC for an ascending sort (which is the default) or ORDER BY field_name DESC for a descending sort. You can use an ORDER BY clause in a SELECT statement, SELECT LIMIT or DELETE LIMIT statement. For example: SELECT * FROM addressORDER BY name ASC; The code above retrieves data from an address book and sorts the results by the person's name in an ascending fashion. SELECT email FROM addressORDER BY email DESC; This code selects only the email addresses and lists them in descending order. Note: If you don't use an ASC or DESC modifier in the ORDER BY clause, the data is sorted by expression in ascending order, which is the same as specifying ORDER BY expression ASC. Cite this Article Format mla apa chicago Your Citation Bradley, Angela. "Ordering MySQL Data." ThoughtCo, Aug. 26, 2020, thoughtco.com/ordering-mysql-data-2693870. Bradley, Angela. (2020, August 26). Ordering MySQL Data. Retrieved from https://www.thoughtco.com/ordering-mysql-data-2693870 Bradley, Angela. "Ordering MySQL Data." ThoughtCo. https://www.thoughtco.com/ordering-mysql-data-2693870 (accessed June 9, 2023). copy citation