What is the difference between NULL and zero in MySQL?

NULL and zero are fundamentally different in MySQL -- NULL represents the absence of a known value, while zero (0) is a real, defined numeric value. Treating them as interchangeable leads to subtle bugs, especially in arithmetic and conditional logic.

Key Points

Example

In a payments table, a NULL amount means no payment has been recorded yet (still pending), while an amount of 0 means a payment was attempted but resulted in no charge, such as a failed or waived transaction -- two very different business states that would be conflated if NULL and 0 were treated the same.

SELECT payment_id, amount,
       CASE
           WHEN amount IS NULL THEN 'Pending'
           WHEN amount = 0 THEN 'Failed'
           ELSE 'Paid'
       END AS status
FROM payments;

Common Mistakes

Follow-up Questions

Interview Tip

A concise interview answer is

NULL represents an unknown or missing value, while zero is an actual numeric value, and that distinction matters -- NULL propagates through arithmetic so NULL + 1 is NULL, not 1, and NULL requires IS NULL rather than an equality check. In a payments table, for example, I'd use NULL to mean 'not yet charged' and 0 to mean 'charged but the amount was zero,' since collapsing those into one value would hide real business meaning.

Last updated: 11 November 2026

Previous question: What is a foreign key constraint?

Next question: What is a database transaction?

More SQL interview questions

All SQL questions