efficient way to update a selection of rows' field to 0, but set One of these rows to 1 based on an ID.
UPDATE `table` SET `inuse` = (`id` = 23) WHERE <condition>
Example:
UPDATE `communication` SET `is_default` = (`id` = 1 and `empid` = 1) WHERE empid = 1
https://stackoverflow.com/questions/1013042/mysql-updating-all-rows-setting-a-field-to-0-but-setting-one-rows-field-to-1
No comments:
Post a Comment