List:General Discussion« Previous MessageNext Message »
From:Martijn Tonies Date:August 31 2004 12:40pm
Subject:Re: Concat
View as plain text  
> Concat() returns Null if any field in the field list
> is Null.  How can I use it to return a String
> regardless, or is there another function to do it?

COALESCE(value,...)
Returns the first non-NULL value in the list.
mysql> SELECT COALESCE(NULL,1);
        -> 1
mysql> SELECT COALESCE(NULL,NULL,NULL);
        -> NULL
COALESCE() was added in MySQL 3.23.3.

So, if you use CONCAT(COALESCE(Myfield, ''), COALESCE(OtherField, '') )

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com

Thread
ConcatA Z31 Aug
  • Re: ConcatMikhail Entaltsev31 Aug
  • Re: ConcatMartijn Tonies31 Aug