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.

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

\n

💻 Live Code Editor

Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.
Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.

💻 Live Code Editor

Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें. Agar load na ho to naye tab mein kholें.