SQL Tutorial

SELECT, WHERE and ORDER BY

Read data with projection, filtering, sorting and limiting.

Concept

SELECT chooses columns or expressions to return. WHERE filters rows before they reach later query stages, and ORDER BY controls result ordering.

Avoid SELECT * in production-facing queries when you only need a few columns because explicit selections communicate intent and reduce unnecessary data transfer.

Example

SELECT name, city
FROM students
WHERE city = 'Jaipur'
ORDER BY name ASC;
Type the example yourself and change at least one value. Small experiments reveal syntax and behavior faster than passive reading.

Practice Tasks

  1. Select only two columns from a table.
  2. Filter rows using comparison and AND/OR.
  3. Return the five highest-priced courses.

Key Takeaways

  • SELECT chooses output columns.
  • WHERE filters rows.
  • ORDER BY makes result ordering explicit.