List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 7 2003 5:14am
Subject:Re: Bug with CONCAT and NULL values?
View as plain text  
At 21:03 -0700 5/6/03, Daevid Vincent wrote:
>Is this a bug? It seems that if I have a "ku_appliance_notes text" field
>defined in a schema, then this UPDATE will fail. It will work however if I
>change the schema to "ku_appliance_notes text NOT NULL,". So it appears that
>CONCAT will not work if the original value is NULL. *sigh*

Correct.  CONCAT() returns NULL if any of its arguments are NULL.
Just like the manual says:

http://www.mysql.com/doc/en/String_functions.html

You might want to use CONCAT_WS() with an empty separator string.
CONCAT_WS() ignores NULL arguments.

>
>UPDATE sku_appliance_table SET sku_appliance_notes = CONCAT('Daevid
>Wrote:<BR>',sku_appliance_notes) WHERE sku_appliance_id = '1' LIMIT 1;
>
>Also, I tried to set the default in the schema to "default ''", but it seems
>that it doesn't take.

Right.  TEXT and BLOB columns cannot be assigned default values.


-- 
Paul DuBois
http://www.kitebird.com/
sql, query
Thread
Bug with CONCAT and NULL values?Daevid Vincent7 May
  • Re: Bug with CONCAT and NULL values?Paul DuBois7 May