Tuesday, July 28, 2009

COALESCE

This function was hard for me to first understand, but I have found it very useful:
COALESCE(expression1,expression2)
means if expression1 is null, then expression2

This was useful when a column originally contains null values and I needed to concatenate a value to it, not knowing if the value was still null

COALESCE(column1,'') means if column1 is null, then blank, otherwise column1

No comments:

Post a Comment