List:General Discussion« Previous MessageNext Message »
From:Almar van Pel  Date:February 22 2011 11:46am
Subject:contact gives empty result
View as plain text  
Hello all,


I'm trying to get a TEXT field updated with its own content and an extra
string by using concat. The query looks something like this:


update field_comment set field_comment = concat(field_comment, '\n


I've noticed that in this case the update doesn't work when the content of
the field is empty.  I tried setting up a testcase, and as long as the
textfield is NULL concat doesn't return anything. Is this 'as designed' or a
bug? Should it work as designed, would anyone know another easy way without
setting a byte first?


Below the testcase:


CREATE TABLE memo_test (id INT (1) UNSIGNED DEFAULT '0' NOT NULL, comments

INSERT INTO memo_test (id, comments) VALUES (1, NULL);

INSERT INTO memo_test (id, comments) VALUES (2, 'Hello');


select concat(comments, 'Does not work') from memo_test



| concat(comments, 'Does not work') |


| NULL                              |

| HelloDoes not work                |



select concat('Something', comments, 'Does not work') from memo_test;


| concat('Something', comments, 'Does not work') |


| NULL                                           |

| SomethingHelloDoes not work                    |



Best regards,


Almar van Pel     


contact gives empty resultAlmar van Pel 22 Feb
  • Re: contact gives empty resultJoerg Bruehe22 Feb
    • Re: contact gives empty resultJaime Crespo Rinc√≥n22 Feb
      • RE: contact gives empty resultAlmar van Pel 22 Feb