Repaso
EspaƱol

What does SELECT * FROM users WHERE deleted_at = NULL return?

Options

  1. Users with deleted_at NULL
  2. No rows (Correct option)
  3. All rows
  4. An error in all databases

Answer

No rows

Why

NULL means 'unknown'. Comparing anything with unknown gives unknown, even NULL = NULL. WHERE keeps only rows where the condition is TRUE, so no rows match.

The correct way is WHERE deleted_at IS NULL (or IS NOT NULL).

Remember

Use IS NULL, never = NULL.

Key terms

Practice this question in Repaso