Data persistence uses PostgreSQL. Raw SQL builds fluency for interviews and debugging; Knex adds migrations, seeds, and a query builder your Express services call. Learn both: SQL shows what the database actually runs; Knex shows how the app stays maintainable.

How to join tables with SQL — Intermediate

Combine related tables with JOIN to return denormalized result sets.
Learn: JOINs combine tables in one query. INNER JOIN keeps rows that match both sides; LEFT JOIN keeps all left rows even when the right side is missing—common for optional relationships.

Supplementary examples

Pastes with usernames

SELECT pastes.paste_id, pastes.name, users.username
FROM pastes
INNER JOIN users ON pastes.user_id = users.user_id;

Course example

SELECT *
FROM departments
JOIN employees
ON departments.manager = employees.employee_id;

Additional references & examples

← All Raw SQL · SQL / Knex