I was recently asked a question by a friend using Borland Interbase on how to do a COALESCE().
Well, we went through every function I could muster, and none of them worked:COALESCE is an ANSI SQL function that returns the first non-null value in a sequence. For instance, COALESCE(null, null, null, 1, null, 2) would return 1
- COALESCE() - the ANSI standard
- ISNULL() - the Microsoft T-SQL standard (only takes two values)
- IFNULL() - the MySQL standard (only takes two values)
- NVL() - Oracle / Informix PL/SQL standard (only takes two values)
It seems there are databases without inate COALESCE() support. for those databases, it's best to use the following type of query:
We tried this out, and it worked well. Hope it helps someone !!Code:SELECT (CASE WHEN column IS NULL THEN 'Alternate Value' ELSE column END) AS column FROM table