×

sql · level 1 · unit 3 · lesson 2

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

shows only the first few rows.

Some tables have thousands of rows, and you want only a handful. LIMIT 3 at the very end of a query stops the result after three rows.

On its own, LIMIT gives you whichever rows come first. Put ORDER BY in front and it becomes a top three: sort biggest first, then keep three.

The parts of a query always go in this order: SELECT, FROM, WHERE, ORDER BY, then LIMIT, last of all.

SELECT player, points FROM scores ORDER BY points DESC LIMIT 3;

Ask for more rows than there are and you get every row, with no error.