Join Bill Weinman for an in-depth discussion in this video Sorting results with ORDER BY, part of MySQL Essential Training (2014).
…The order by clause is used to sort the results of a query, here's how it works.…Select the world database here in SID.…And if I say select name from country like…that, you'll notice that the names are not in any particular order.…Yeah a lot of the a's are before a lot of the b's but there's still…other stuff you know, there's Switzerland in with…the c's and it's not really in order.…The order by clause is how you put things in order in your result sets.…
So if I say order by name and select…Go, then it is now in alphabetical order by name.…See all the c's are after all the b's and then…there's the d's and you'll notice that they're all in order now.…Now what if I don't want them in ascending order?…So if instead I want it in descending order, I can just put DESC which is an SQL…keyword after the word name and order by, so…it's order by name descending is how that would read.…
And I press Go and now I have the z's at the top…followed by the y's and the w's and the v's and that's descending order.…The natural default order is ascending and it does…
- Writing queries
- Creating and updating databases and tables
- Using MySQL built-in functions
- Sorting and filtering data
- Updating tables with triggers
- Working with subselects and views
- Creating and using a stored function
Skill Level Beginner
1. Installing and Configuring the Test Environment
2. Basic Syntax
3. Creating a Database
4. MySQL Data Types
5. MySQL Functions
8. Subselects and Views
9. Stored Routines
10. PHP's PDO Interface with MySQL
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.