Skip to content
Advertisement

How to update two columns in one column with two different ID and different value in single SQL query?

I have a table Item:

How to update the price column id(1) = 1000, id(2) = 2000 in a single SQL query?

Advertisement

Answer

Use case:

You can also write this using a from clause:

This is a bit safer as well, ensuring that the ids really do match an no extra rows are accidentally updated.

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