MySQL Null Functions

Handling NULL.

MySQL functions for handling NULL values

MySQL has the following functions to work with NULL values:

  • IFNULL()
  • COALESCE()

IFNULL() returns the specified value if the expression is NULL.

COALESCE() returns the first non-NULL value in the list.

Example

SELECT ProductName, UnitPrice * (UnitsInStock + IFNULL(UnitsOnOrder, 0)) FROM Products;