Flashcards · SQL · Free
SQL flashcards, generated for you.
Example SQL study cards to learn from right now — then generate a full set from your own notes (plus a practice quiz) and export to Quizlet or Anki. Free, no account needed.
Example SQL flashcards
What does SQL stand for and what is its primary purpose?
Structured Query Language. It's used to query, insert, update, and delete data in relational databases using declarative statements.
What is the correct order of SQL clause execution?
FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. Note: SELECT is evaluated after WHERE and GROUP BY, not before.
What is the difference between WHERE and HAVING?
WHERE filters rows before aggregation (GROUP BY). HAVING filters groups after aggregation. WHERE works on raw columns; HAVING works on aggregate functions like COUNT(), SUM().
Why does SELECT * with GROUP BY often cause errors?
Non-aggregated columns in SELECT must appear in GROUP BY or be wrapped in an aggregate function. Without aggregation logic, the database doesn't know which row value to return for that column per group.
What is the difference between INNER JOIN, LEFT JOIN, and FULL OUTER JOIN?
INNER: returns only matching rows from both tables. LEFT: returns all rows from left table + matching rows from right (NULLs for non-matches). FULL OUTER: returns all rows from both tables with NULLs where no match.
Why might NULL values cause unexpected results in WHERE clauses?
NULL comparisons always evaluate to UNKNOWN, not TRUE or FALSE. WHERE NULL = NULL returns UNKNOWN (not TRUE). Use IS NULL or IS NOT NULL to check for NULLs explicitly.
What is the difference between UNION and UNION ALL?
UNION removes duplicate rows from the result set and sorts data (slower). UNION ALL keeps all rows including duplicates (faster). Both require same number and types of columns in each SELECT.
What does a subquery in the WHERE clause with IN vs. EXISTS do differently?
IN checks if a value exists in a returned list; executes the subquery fully. EXISTS stops checking once a match is found (more efficient). EXISTS is preferred for large subqueries as it short-circuits.
How do aggregate functions like COUNT(), SUM(), AVG() handle NULL values?
They skip/ignore NULL values in calculations. COUNT(column) ignores NULLs; COUNT(*) counts all rows. SUM(NULL) + 5 = NULL (NULL propagates). Use COALESCE() to handle NULLs in aggregates.
What is the performance gotcha with using functions on indexed columns in WHERE clauses?
WHERE UPPER(name) = 'JOHN' prevents index usage on the name column because the index stores original values. Write WHERE name = 'JOHN' instead, or use functional indexes if available.
Make your own SQL study set
Flashcards for related topics
Studying SQL to build with AI? MindloomHQ turns it into real skills — structured courses, agent projects, and certificates.
Explore MindloomHQ →