Is there an efficient way to update a selection of rows’ field to 0, but set One of these rows to 1 based on an ID.
Basically, I have multiple objects in a database, and I want to toggle between which one is “inuse”, so the query will set one of the rows (by id) to inuse=1 and the others to inuse=0.
Thanks 🙂
Advertisement
Answer
UPDATE `table` SET `inuse` = (`id` = 23)