MySQL update conditions in one query (UPDATE, SET & CASE)
问题 I'm trying to update a set of records ( boolean fields ) in a single query if possible. The input is coming from paginated radio controls, so a given POST will have the page's worth of IDs with a true or false value. I was trying to go this direction: UPDATE my_table SET field = CASE WHEN id IN (/* true ids */) THEN TRUE WHEN id IN (/* false ids */) THEN FALSE END But this resulted in the "true id" rows being updated to true , and ALL other rows were updated to false . I assume I've made some