13.03.2018, 20:45
I think that this should work if I understand the problem correctly:
We try to set `archivedex` first depending on the value of `archived` -- only if `archived` is 1 then it will update. Then we try to set `archived` to 1 if it is currently 0. If we tried to update `archived` first then it could get set to 1 and then subsequently the `archivedex` will get set too which is not what we want in your case (only one column is to be updated in the query).
Код:
UPDATE `acc_mobile_messages` SET `archivedex` = (CASE `archived` WHEN 1 THEN %i ELSE `archivedex` END), `archived` = (CASE `archived` WHEN 0 THEN %i ELSE `archived` END) WHERE `databaseId` = %i;