Database Reference
In-Depth Information
▼
Output
+------------+
| prod_price |
+------------+
| 55.00 |
+------------+
▼
Analysis
prod_price DESC
ensures that rows are retrieved from most to least expen-
sive, and
LIMIT 1
tells MariaDB to just return one row.
Caution
Position of
ORDER BY
Clause When specifying an
ORDER BY
clause, be sure that
it is after the
FROM
clause. If
LIMIT
is used, it must come
after
ORDER BY
. Using
clauses out of order generates an error message.
In this chapter, you learned how to sort retrieved data using the
SELECT
state-
ment's
ORDER BY
clause. This clause, which must be the last in the
SELECT
statement, can be used to sort data on one or more columns as needed.