SQL LESSON 9 OF 32

NULL: a missing value

NULL means missing or unknown, not zero or an empty string. Use IS NULL and IS NOT NULL. Comparing NULL with = does not produce true. COALESCE returns the first non-NULL value.

हिन्दी में समझें

NULL का अर्थ गायब या अज्ञात है, शून्य नहीं। IS NULL और IS NOT NULL लें। = NULL सही जाँच नहीं है। COALESCE पहला गैर-NULL मान देता है।

अभ्यास: मैनेजर वाले कर्मचारियों के name, id क्रम में दिखाएँ।

Hinglish mein samjhein

NULL missing ya unknown hai, zero nahi. IS NULL ya IS NOT NULL use karo. = NULL sahi check nahi. COALESCE first non-NULL value deta hai.

Practice: Manager wale employees ke name id order mein dikhao.

A small SQL example

SELECT name FROM employees WHERE manager_id IS NULL;

Examples use the fictional shop database bundled with the SQL playground: customers, products, orders, order_items and employees. The engine is SQLite; other SQL dialects may differ.

Try this example in the SQL playground →

Practise this idea

Show employee names with a manager, ordered by id.

Check answer & explanation
SELECT name FROM employees WHERE manager_id IS NOT NULL ORDER BY id;

IS NOT NULL tests that a manager reference exists. It does not confuse a missing value with zero or an empty string.

Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.

Check your understanding

To find missing values use…

  1. = NULL
  2. IS NULL
  3. == ""
Check the quiz answer

IS NULL

NULL means missing or unknown, not zero or an empty string. Use IS NULL and IS NOT NULL. Comparing NULL with = does not produce true. COALESCE returns the first non-NULL value.

References & corrections

Use the official SQLite documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.

FROM LEARNING TO BUSINESS RESULTS

Need a dashboard for your team?

Excel Keys designs custom Excel and HTML dashboards around your own KPIs and Excel files. They run offline in the browser, so your data stays on your computer.