Hillary Chege
Crafting Digital Excellence

Code Snippets

Useful code examples and solutions I've collected. Feel free to use and learn from them!

sql_join_query.sql ×

// SQL JOIN Query

// Join multiple tables to get related data

SELECT 
    users.name,
    orders.order_date,
    products.product_name,
    order_items.quantity
FROM users
INNER JOIN orders ON users.id = orders.user_id
INNER JOIN order_items ON orders.id = order_items.order_id
INNER JOIN products ON order_items.product_id = products.id
WHERE users.id = 1
ORDER BY orders.order_date DESC;