Guides › FULL OUTER JOIN

FULL OUTER JOIN in SQL Server: both leftovers

FULL OUTER JOIN keeps matches and also the leftovers from both tables. At work that is “in A but not B, in B but not A, and in both.”

Products vs a stock list

SELECT p.product_id, p.product_name, s.qty_on_hand
FROM Products p
FULL OUTER JOIN Stock s ON s.product_id = p.product_id;

A product with no stock row still shows (qty NULL). A stock row for a deleted product still shows (name NULL).

You probably wanted two LEFT JOINs

FULL OUTER is rare in day-to-day reports. Reconciling two extracts is the honest use. For “all customers and their orders”, LEFT JOIN is enough.

Try it on Harbour & Co

Becky Ashworth (Support) needs this now: “Who signed up but never ordered? I want to send them a nudge.” Write the query, run it, send the results. On the paid plan.

Take the ticket →

Learn it on a real ticket

Monday is free on WorkSQL. A colleague’s ticket lands, you write the T-SQL, we mark it. No videos. Five minutes.

Clock in free See Monday’s tickets