SQL Basics

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/30

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:02 PM on 6/2/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

31 Terms

1
New cards

SELECT

Retrieves columns from a table

2
New cards

WHERE

Filters rows based on a condition. Evaluated before aggregation. Cannot reference column aliases.

3
New cards

GROUP BY

Groups rows by specified column(s). Always used with aggregate functions.

4
New cards

HAVING

Filters groups AFTER GROUP BY. Like WHERE but for aggregated results. Can reference aliases.

5
New cards

ORDER BY

Sorts the result set. Use ASC (default) or DESC. Applied last in query execution.

6
New cards

LIMIT / TOP

Restricts number of rows returned. MySQL/PG: LIMIT n | SQL Server: TOP n

7
New cards

DISTINCT

Returns unique rows only. SELECT ______ col FROM table

8
New cards

AS

Creates an alias for a column or table

9
New cards

INNER JOIN

Returns only rows with matching values in BOTH tables.

10
New cards

LEFT JOIN

All rows from the left table + matching rows from right. Non-matches = NULL on right side.

11
New cards

RIGHT JOIN

All rows from the right table + matching rows from left. Non-matches = NULL on left side.

12
New cards

FULL OUTER JOIN

All rows from both tables. Non-matches on either side filled with NULL.

13
New cards

CROSS JOIN

Returns the Cartesian product — every combination of rows from both tables. No ON clause.

14
New cards

UNION

Combines result sets of two queries, removing duplicates. Columns must match.

15
New cards

UNION ALL

Combines result sets of two queries, keeping duplicates. Faster than UNION.

16
New cards

IN

Checks if a value exists in a list

17
New cards

NOT IN

Removes rows where value is found in list. Caution: returns nothing if list contains NULL.

18
New cards

BETWEEN

Inclusive range filter. WHERE col ______ 1 AND 10 — equivalent to col >= 1 AND col <= 10

19
New cards

LIKE

Pattern matching. % = any number of chars, _ = single char

20
New cards

IS NULL

Checks for NULL values. Cannot use = NULL — must use _________

21
New cards

IS NOT NULL

Checks that a value is not NULL.

22
New cards

COUNT(*)

Counts all rows including NULLs

23
New cards

SUM(col)

Returns total sum of a numeric column. Ignores NULLs.

24
New cards

AVG(col)

Returns the arithmetic mean. Ignores NULLs — may differ from SUM/COUNT.

25
New cards

MIN(col) / MAX(col)

Returns the smallest or largest value in a column.

26
New cards

CASE WHEN

Conditional logic

27
New cards

COALESCE(a, b, c)

Returns the first non-NULL value in the list. Commonly used for NULL fallbacks.

28
New cards

NULLIF(a, b)

Returns NULL if a equals b, otherwise returns a. Used to avoid divide-by-zero.

29
New cards

CAST(col AS type)

Converts a value to a specified data type

30
New cards

Subquery

A query nested inside another query. Can appear in SELECT, FROM (derived table), or WHERE.

31
New cards

Execution Order

FROM → JOIN → WHERE → GROUP BY → HAVING → SELECT → DISTINCT → ORDER BY → LIMIT