ORDER BY

This lesson discusses how to use the ORDER BY clause.

We'll cover the following

ORDER BY Clause

In the previous couple of sections, we have seen how to query data from a table. The retrieved rows aren’t printed in any particular order. The ORDER BY clause allows us to print the retrieved rows in an orderly fashion based on the criteria we specify.

Example Syntax

SELECT col1, col2, … coln

FROM table

WHERE col3 LIKE "%some-string%"

ORDER BY col3

Connect to the terminal below by clicking in the widget. Once connected, the command line prompt will show up. Enter or copy and paste the command ./DataJek/Lessons/11lesson.sh and wait for the mysql prompt to start-up.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.