EasyJOINs (INNER, LEFT, RIGHT, FULL)

Get all orders with customer names

The query

SQL
SELECT
  o.order_id,
  c.name AS customer_name,
  o.order_date,
  o.total,
  o.status
FROM orders o
JOIN customers c ON o.cust_id = c.cust_id
ORDER BY o.order_date DESC;
Tested against PostgreSQL 16

Note

Always alias tables with single letters (e, d, o, c) for cleaner, shorter queries.

Tables referenced