INNER JOIN with Multiple Tables

Performs INNER JOINs across three tables to combine related data from customers, orders, and products with proper table aliasing and filtering.

SqlData Fetching

Code

snippet
SELECT
    c.customer_id,
    c.first_name,
    c.last_name,
    o.order_id,
    o.order_date,
    p.product_name,
    oi.quantity,
    oi.unit_price,
    oi.quantity * oi.unit_price AS line_total
FROM customers c
INNER JOIN orders o ON c.customer_id = o.customer_id
INNER JOIN order_items oi ON o.order_id = oi.order_id
INNER JOIN products p ON oi.product_id = p.product_id
WHERE o.order_date >= '2025-01-01'
  AND o.status = 'completed'
ORDER BY o.order_date DESC, c.last_name ASC;