Reputation: 553
in my table a column selected contains default value null, but i want to update the column by appending a string to it with a condition that if the field contains null then it should be updated else if it contains any other string then i need to update it like update tabname set colname=concat(colname,',newString')? any information would be a great help for me thanks in advance...
Upvotes: 2
Views: 1112
Reputation: 64466
You can use case
update tabname
set colname= case when colname is null or colname =''
then 'newString'
else concat(colname,'newString')
end
Upvotes: 5