T-SQL reference › IN
IN and NOT IN in SQL Server
IN is “equals any of these.” Fine for a short list you wrote. NOT IN plus a subquery that can return NULL is a well-known trap.
A list you wrote
SELECT order_id, status, total_amount
FROM Orders
WHERE status IN ('Shipped', 'Processing')
ORDER BY order_id;
NOT IN (SELECT phone …)
If one phone is NULL, the whole NOT IN becomes unknown, and you get no rows. Use NOT EXISTS or WHERE phone NOT IN (…) AND phone IS NOT NULL. Prefer NOT EXISTS.
Try it on Harbour & Co
Tom Gallagher (Warehouse Lead) needs this now: “Which orders are still Processing? I need order_id, order_date and total_amount.” Write the query, run it, send the results. Free.
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