ISNULL()

From Lianjapedia
Revision as of 05:56, 15 April 2013 by Yvonne.milne (Talk | contribs)

Jump to: navigation, search

Purpose

Function to specify an alternative value for a null expression

Syntax

ISNULL(<expr1>, <expr2>)

See Also

COALESCE(), EMPTY(), IFNULL(), ISALPHA(), ISBLANK(), ISDIGIT(), NVL(), SET NULL, SET NULLDISPLAY

Description

The ISNULL() function evaluates the expression in <expr1>, and if the expression does not evaluate to NULL, the evaluated result is returned. If the expression in <expr1> does evaluate to NULL, the expression in <expr2> is evaluated. If <expr2> does not evaluate to NULL, the evaluated result is returned. If both <expr1> and <expr2> evaluate to NULL, the ISNULL() function returns NULL.

Example

set null on
CREATE TABLE nullon (firstname c(20), lastname c(20))
INSERT INTO nullon (lastname) VALUES ("Smith")
SELECT lastname, isnull(firstname,"Unknown") from nullon