Difference between revisions of "IFNULL()"
From Lianjapedia
Yvonne.milne (Talk | contribs) (→Description) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
==See Also== | ==See Also== | ||
− | [[EMPTY()]], [[ETOS()]], [[EVL()]], [[ISNULL()]], [[NVL()]], [[SET NULL]], [[SET NULLDISPLAY]] | + | [[COALESCE()]], [[EMPTY()]], [[ETOS()]], [[EVL()]], [[ISNULL()]], [[NVL()]], [[SET NULL]], [[SET NULLDISPLAY]] |
==Description== | ==Description== | ||
− | The IFNULL() 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 | + | The IFNULL() 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 IFNULL() function returns NULL. |
==Example== | ==Example== | ||
Line 21: | Line 21: | ||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | [[Category: | + | [[Category:Formatting Functions]] |
− | + |
Latest revision as of 09:09, 19 October 2023
Contents
Purpose
Function to specify an alternative value for a null expression
Syntax
IFNULL(<expr1>,<expr2>)
See Also
COALESCE(), EMPTY(), ETOS(), EVL(), ISNULL(), NVL(), SET NULL, SET NULLDISPLAY
Description
The IFNULL() 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 IFNULL() function returns NULL.
Example
set null on CREATE TABLE nullon (firstname c(20), lastname c(20)) INSERT INTO nullon (lastname) VALUES ("Smith") SELECT lastname, ifnull(firstname,"Unknown") from nullon