W
webklip
webklip.com/
sql-joins-cheatsheet
0 devices
Public
API
Share
Copy link
Show QR code
Share via apps
This public clip is view-only.
Content
Preview
-- SQL joins cheat sheet -- INNER JOIN: rows matching in both tables SELECT u.name, o.total FROM users u INNER JOIN orders o ON o.user_id = u.id; -- LEFT JOIN: all users, orders when present SELECT u.name, o.total FROM users u LEFT JOIN orders o ON o.user_id = u.id; -- RIGHT JOIN: all orders, users when present SELECT u.name, o.total FROM users u RIGHT JOIN orders o ON o.user_id = u.id; -- FULL OUTER JOIN (when supported) SELECT u.name, o.total FROM users u FULL OUTER JOIN orders o ON o.user_id = u.id; -- Anti-join: users with no orders SELECT u.* FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE o.id IS NULL; -- Self join SELECT e.name AS employee, m.name AS manager FROM employees e LEFT JOIN employees m ON m.id = e.manager_id; -- Tip: filter on the outer table in WHERE carefully — -- predicates on the right table of a LEFT JOIN can turn it into an INNER JOIN.
Editor
Files
Scan to open
webklip.com/
sql-joins-cheatsheet
Developer docs
Open page
REST API
Webhooks
Loading documentation…