Reputation: 117
i have the following situation :
I need to update customer information on a field in a database specifically on customers not in the EU. I've already selected and filtered the customers, now i've got the following question.
There is a field lets call it "order_note" which i need to update. I know how to do that normally, but some of the fields contain notes that had been set by hand and i don't want to loose them, but also add a "Careful! Think of XY here" in the field - best before the other information. Is it possible to update a field that already contains content without deleting it?
Thanks for any advice
Upvotes: 2
Views: 1808
Reputation: 1
Yes.
I think you are asking "how to join a new string to your already existed filed data." You need to figure out how to concat string in your data base.
for example , Mysql use CONCAT() function and sqlserver use "+" operator.
Here is my mysql code:
UPDATE test_table SET note = CONCAT('some notice info..',note);
before this code was submitted, the node data is 'hello.'
and after, it changes to 'some notice info...hello'.
Upvotes: 0
Reputation: 16037
update customer_information
set order_note = 'Careful! Think of XY here!\n' || order_note
where customer_region != 'EU'
Upvotes: 1
Reputation: 6020
UPDATE OrderTable
SET order_note = 'Careful! Think of XY here. ' + order_note
WHERE order_id = 1
Upvotes: 4