This shows you the differences between two versions of the page.
dev:sql:functions:ifnull [2009/12/07 15:25] tdo created |
dev:sql:functions:ifnull [2016/06/28 22:38] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{page>:top_add&nofooter&noeditbtn}} | ||
- | <html><div align="center"><span style="color:red">DRAFT</span></div></html> | ||
- | ====== Omnidex SQL Function: $IFNULL ====== | ||
- | {{page>:sql_bar&nofooter&noeditbtn}} | ||
- | ===== Description ===== | ||
- | $IFNULL specifies a return value for columns that contain null values. The column data type and the return value data type must match. | ||
- | If column-value is NULL then return specified-value, else return column-value | ||
- | |||
- | Use of this function could change the results of a calculated average. A true NULL is generally not included in a count and thus not included in an average. A NULL altered with this function will be included in the count and the average. | ||
- | ===== Syntax ===== | ||
- | |||
- | $IFNULL(column_spec, specified-value) | ||
- | |||
- | == column_spec == | ||
- | |||
- | Required. Column name that might contain a null value. | ||
- | |||
- | == specified-value == | ||
- | |||
- | Required. The value to return if the column value is null. This value must be of the same data type as the column. | ||
- | ===== Example ===== | ||
- | |||
- | ==== Example 1 ==== | ||
- | <code SQL> | ||
- | select company, | ||
- | $IFNULL(contact, 'No contact') | ||
- | from customers | ||
- | where state = 'ca' | ||
- | </code> | ||
- | {{page>:bottom_add&nofooter&noeditbtn}} |