SELECT, WHERE and ORDER BY

Read specific columns, filter rows and sort results.

Notes

SELECT chooses columns, FROM chooses the table, WHERE keeps matching rows and ORDER BY sorts the output.

Combine conditions with AND / OR and use parentheses when mixing them.

Key points

  • WHERE filters rows before grouping.
  • ORDER BY can use several columns.
  • Name columns clearly with AS.