MySQL: Updating all rows setting a field to 0, but setting one row's field to 1

 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


Comments

Popular posts from this blog

Android App Version Update using the following cordova cli commands

75 inspirational quotes that will change your life

Retrieval Image From DataBase and Display on WebPage by Using Servlets.