Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Databases
Databasesmedium

SQL NULL: why is `col = NULL` not true and what should you use?

Tags
#sql#null#three-valued-logic#bugs
Back to categoryPractice quiz

Answer

NULL means “unknown”, so comparisons like `col = NULL` evaluate to UNKNOWN, not true/false (3-valued logic). Use `IS NULL` / `IS NOT NULL`, and in some DBs `IS DISTINCT FROM` to compare safely with NULLs.

Related questions

Databases
Why can `LIKE '%term%'` be slow and what are common alternatives?
#sql#like#indexes
Databases
Why is `SELECT *` risky in production queries?
#sql#best-practices#performance
Databases
What is a window function in SQL and a typical use case?
#sql#window-functions#row_number
Databases
GROUP BY vs HAVING — what’s the difference?
#sql#group-by#having
Databases
INNER JOIN vs LEFT JOIN — what’s the difference?
#sql#join#inner-join
Databases
SQL vs NoSQL?
#sql#nosql#comparison