Skip to content
Advertisement

Update multiple columns/rows case statement SQL

I have looked at similar questions previously but they seem to update a single column with multiple case conditions and the one answer I found for multiple columns seems a little long.

Let’s say I have a table like this:

Column_1 Column_2 Column_3 Column_4 Column_5
First Value 1
Second Value 2
…. ….
Twelfth Value 3

I want to use column_1 as a key and update column 3, column 4 and column 5 with known values.

My initial query guess was:

The solution for a similar question was

Would my initial query work? Or am I looking for a different SQL feature like Duplicate keys? I read up on a MySQL If() function but I’m working with Microsoft SQL. Thanks for the help!

Advertisement

Answer

may be you are looking for something like this:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement