Changes

Sorting Data Retrieved from a MySQL Database

15 bytes added, 20:20, 11 October 2007
no edit summary
Now that we have looked at the basics of [[Retrieving Data From a MySQL Database|retrieving data from a MySQL database]] and before we look and [[Using WHERE to Filter MySQL Data|filtering retrieved data]] we need to look at how to sort the output from a database retrieval.
== Sorting SELECTed data Data from a SELECT Statement ==
In the previous chapter we look at the SQL SELECT statement and how it is used to retrieve data from a database. Typically, a SELECT statement will extract the data from a table in the order in which it was added. Thius, however, can change if the database table has been subjected to updates and deletions. Quite simply, there is no way to predict the exact order in which data will be retrieved. For this reason SQL provides the ''ORDER BY'' keywords which enable us to sort the data as it is retrieved by the SELECT statement.