Skip to content
Advertisement

Update a single column on multiple rows with one SQL query

I need to update a single column over a thousand rows in the database. Normally when I need to do this, I’ll do the following:

I feel like there should be a way to do this easily, but after searching around online, I cannot find a solution.

What I was hoping for was this:

An important piece of information to note is that I am always setting one column, the same column across a specific set of rows.

Does anyone know the best way to do this?

Advertisement

Answer

You can actually do it using insert into …on duplicate key update

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