SELECT query vocabulary

  • SELECT col FROM tbl WHERE cond ORDER BY col ASC/DESC — the core pattern
  • INNER JOIN — only matched rows; LEFT JOIN — all left + matched right (NULL if no match)
  • DISTINCT — deduplicate: returns unique rows only
  • AS alias — temporary name for a table or column in this query only
  • Subquery (SELECT ...) in WHERE — runs first; outer query uses its result as a value

Question 0 of 5

Read this SQL query and describe what it does in one sentence:

SELECT first_name, last_name, email FROM users WHERE active = true ORDER BY last_name ASC;