Concatenating field values to update one column

update table_name set column_1=column_1||column_2;

Or

update table_name set column_1=concat(column_1,column_2);

 

Example:

In that example I want to add ‘;authid:’ and id at the end of attributes column where id is 115476

select id,attributes from TEST;

id

Attributes

115476

abortError=5410;confirmResponse=ABORTED;abortSleep=200

115478

abortError=5412;confirmResponse=ABORTED;abortSleep=200

115480

abortError=5498;confirmResponse=ABORTED;abortSleep=200

115482

abortError=5401;confirmResponse=ABORTED;abortSleep=200

 

update test set attributes = attributes||';authid:'||id where id = '115476';

Or

update test set attributes = concat(concat(attributes,';authid:'), id) where id = '115476';

 

select id,attributes from TEST;

id

Attributes

115476

abortError=5410;confirmResponse=ABORTED;abortSleep=200;authid:115476

115478

abortError=5412;confirmResponse=ABORTED;abortSleep=200

115480

abortError=5498;confirmResponse=ABORTED;abortSleep=200

115482

abortError=5401;confirmResponse=ABORTED;abortSleep=200

 

Comments