SQL Practice Logo

SQLPractice Online

Multiple Table Joins: Functions

Module: Joins & Relationships

SELECT * FROM orders o INNER JOIN customers c ON o.customer_id = c.id INNER JOIN products p ON o.product_id = p.id;

Chain joins with multiple JOIN clauses

Each join needs its own ON clause

Joins execute left-to-right

Can mix INNER and LEFT joins

Use table aliases for readability

Core references in this topic include WHERE, =, <, >, <=, >=. Learn what each one does, when to use it, and the execution or engine rules that matter.

WHERE

Filters rows before projection and sorting. It decides which rows continue through the query pipeline.

SELECT ... FROM table WHERE condition;

Most performance issues start with a weak WHERE clause or a missing supporting index.

=

Returns rows where the left and right values are exactly equal.

column = value

Use with exact matches. Do not use = NULL.

<, >, <=, >=

Range comparison operators for less-than, greater-than, and inclusive boundary checks.

salary >= 80000

ANY / ALL

Compares one value against every or at least one value from a subquery result.

salary > ALL (SELECT salary FROM interns)

INTERVAL

Represents a duration that can be added to or subtracted from dates and timestamps.

order_date + INTERVAL '7 days'

CHECK

Validates a row-level rule whenever data is inserted or updated.

CHECK (salary >= 0)

FILTER

Applies an aggregate only to rows that satisfy an extra predicate.

COUNT(*) FILTER (WHERE status = 'active')

ROWS / RANGE

Defines how a window frame is sliced around the current row.

ROWS BETWEEN 3 PRECEDING AND CURRENT ROW

Chain joins with multiple JOIN clauses

Each join needs its own ON clause

Joins execute left-to-right

Can mix INNER and LEFT joins

Use table aliases for readability

Use meaningful table aliases

Put main entity first