← All snippets
SELECT with JOIN
Combine rows from two tables on a shared key — INNER JOIN returns only matching rows from both sides.
patternsCode
SELECT u.name, COUNT(o.id) AS order_count
FROM users u
INNER JOIN orders o ON o.user_id = u.id
WHERE u.country = "India"
GROUP BY u.id
ORDER BY order_count DESC;