Skip to content
Advertisement

MYSQL Update same column with multiple where clause

I found this question, seems like same as mine. However, there’s a little difference between the two as that one is using the same column in where clause and I have a different one.

This is what I’m trying to achieve;

is it possible to do that in one query?

EDIT: The data type of recent is Boolean, and there should be only one that is set to be TRUE. So I want to set it all back to FALSE to make sure none of them will be true then update the row with ID of 555 to TRUE making it the only one TRUE.

Advertisement

Answer

You could use a case expression:

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