MySQL + SQL · Lesson 49

IS NULL and IS NOT NULL

What is NULL?

NULL means "no value" — empty/unknown. It is NOT the same as 0 or an empty string. You cannot test it with =; use IS NULL.

Examples

-- find students with no phone number
SELECT * FROM students WHERE phone IS NULL;

-- find students who have a phone number
SELECT * FROM students WHERE phone IS NOT NULL;

Common Trap

WHERE phone = NULL does NOT work and returns nothing. Always use IS NULL / IS NOT NULL.

Summary

  • NULL = unknown/missing, not 0 or empty.
  • Test with IS NULL / IS NOT NULL, never = NULL.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

WhatsApp