The NULL in your NOT IN

· Radim Marek · June 14, 2026, 9:42 p.m.
Summary
This blog post delves into the intricacies of SQL's NOT IN clause, emphasizing how a single NULL value in a subquery can lead to unexpected empty result sets. It explains the underlying logic, related parser behavior, and the historical challenges SQL developers face with NULL values. The author suggests alternative approaches such as using NOT EXISTS or ensuring NULLs are filtered out to avoid these pitfalls. The insights shared are both technical and practical, benefitting SQL developers looking to improve their query writing skills.
AUTHOR
Sponsored
Zulip logo Zulip
Organized team chat for people who take work seriously. Topic-based threading keeps conversations focused.
Try Zulip
Become a sponsor →
BLOG POST FEATURED ON

Add this plugin to your blog