Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update various sql columns based on another column of the same row?

I am running SQL Server and am needing to update hundreds of entries. Column A has unique values and based on that I need to update column B of the same table, all with different values. Essentially I am looking for a way to perform the following but in a bulk manner:

UPDATE table
set column B = 'value'
where column A = 'unique value'
like image 239
Chad Avatar asked Jan 25 '26 03:01

Chad


1 Answers

Is this what you are expecting,

UPDATE table
set column B = case when column A = 5 then 'unique string' end;
like image 64
Jim Macaulay Avatar answered Jan 26 '26 18:01

Jim Macaulay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!