CodeNest

WHERE and ORDER BY

Filter rows with WHERE and sort with ORDER BY:

SELECT name FROM products WHERE price < 50 ORDER BY price;        -- ascending
SELECT name FROM products WHERE category = 'hardware' ORDER BY price DESC;

LIMIT n keeps only the first n rows. Combine conditions with AND / OR.

Try it

List the names of the hardware products, most expensive first:

Keyboard
Mouse
SQLite (SQL) in-browser
Next
Loading editor…

Press Ctrl/ + Enter or click Run to see the output here.