"Shaun" <[EMAIL PROTECTED]> wrote on 01/18/2006 10:57:49 AM:

> Hi,
> 
> I am trying to update a field so that it retains its contents plus the 
> contents of another column like this:
> 
> UPDATE MyTable SET Comments = CONCAT(Comments, 'Old_ID_Field = ', 
> Old_ID_Field) WHERE Table_ID = 1;
> 
> However I just get a blank Comments field, any ideas why this is 
happening?
> 
> Thanks for your advice
> 
> 

If either `Comments` or `Old_ID_Field` is null, then the CONCAT() fuction 
will return as NULL. You should probably wrap both fields in something 
like COALESCE() to convert any NULLs to an empty string.

UPDATE MyTable SET Comments = CONCAT(COALESCE(Comments,''), 'Old_ID_Field 
= ', 
COALESCE(Old_ID_Field,'')) WHERE Table_ID = 1;

If that's not it, please post what version you are using, the definition 
of the table you are working with and the results of 

SELECT Comments, Old_ID_Field from MyTable where Table_ID=1;

HTH,

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Reply via email to