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. Used to query, insert, update, and delete data in relational databases.
What is the correct order of SQL clauses in a SELECT statement?
SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY → LIMIT
Why can you not use aggregate functions (COUNT, SUM, AVG) in a WHERE clause?
WHERE filters individual rows before aggregation occurs. Use HAVING after GROUP BY to filter aggregated results instead.
What is the difference between INNER JOIN and LEFT JOIN?
INNER JOIN returns only rows with matches in both tables. LEFT JOIN returns all rows from the left table plus matching rows from the right table (NULLs for non-matches).
In SQL, what does NULL represent and how do you test for it?
NULL represents missing or unknown data. Test with IS NULL or IS NOT NULL; using = NULL always returns false because NULL is not equal to anything, including itself.
What is the difference between GROUP BY and DISTINCT?
DISTINCT removes duplicate rows from results. GROUP BY organizes rows into groups and is required when using aggregate functions; it can also remove duplicates but is slower and designed for aggregation.
When you use GROUP BY without an aggregate function, which column values are returned?
Only the grouped columns and any columns with aggregate functions should be in SELECT. Non-aggregated, non-grouped columns produce undefined behavior in most SQL databases.
What is the difference between UNION and UNION ALL?
UNION combines results from multiple queries and removes duplicate rows (slower). UNION ALL keeps all rows including duplicates (faster). Both require matching column counts and types.
Why might a JOIN produce more rows than expected?
If the join condition matches multiple rows in one or both tables, the result contains all combinations (Cartesian product of matches). Always verify join cardinality with sample data.
What is a subquery and when would you use it instead of a JOIN?
A subquery (nested SELECT) returns data to another query. Use subqueries for: filtering with IN/NOT IN, single aggregate values in WHERE, or when a JOIN would create unwanted duplicates. JOINs are usually faster.
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 →