SQLBeginner#nulls

How do you handle NULL values in SQL?

NULL means unknown, so any comparison with = yields UNKNOWN. Test it with IS NULL / IS NOT NULL and substitute defaults with COALESCE, IFNULL or NVL.

Example
SELECT name, COALESCE(phone, 'not provided') AS phone
FROM customers
WHERE deleted_at IS NULL;

Related Questions

1
SQLBeginner#functions

What is the difference between COALESCE and CASE?

Open
2
SQLAdvanced#windows

What is a window function?

Open
3
SQLAdvanced#windows

Difference between ROW_NUMBER, RANK and DENSE_RANK?

Open