trasaction table description field have some value it is worked fine. description feild default value is NULL,its not works..
update transaction set domain='hiox.com',description=CONACT(description,',domain swapped from hioxindia.com to hiox.com') where id=23602
help me..
When you concatenate any string with a NULL value, it will result in NULL. To avoid this, you can use the COALESCE function. The COALESCE function returns the first non-Null value. So, when there is a value in the column that is not null, that will be concatenated.
We can append a string of data to an existing data of a field by using concat function of MySQL. Here we are not updating or replacing existing data with a new one, we are just adding the string at the end(or at the beginning ) of the field data. Joining strings by using CONCAT and handling NULL value.
MySQL, UPDATE data into a database using CONCAT() If you would like the data that you are entering to appear at the beginning of the existing data, simply flip the concatenation, example: UPDATE table1 SET changelog = CONCAT("new data", changelog) WHERE id = 'idnumber';
Use ifnull()
:
update `transaction`
set domain='hiox.com',
description=CONCAT(ifnull(description, ''), ',domain swapped from hioxindia.com to hiox.com')
where id=23602
Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With