I have a particular MySQL UPDATE
statement which does specify the required primary key in its WHERE
clause and yet which still produces Error 1175 when run in MySQL Workbench.
I am perfectly aware of MySQL error code: 1175 during UPDATE in MySQL Workbench. My case appears to be the same as MySQL error code: 1175 during UPDATE (MySQL-Workbench vs. console). Like that questioner, I do not wish to disable MySQL-Workbench's "safe update/delete" option. That question failed to get a solution. I would like to try to get an actual solution.
SQL UPDATE
statement:
-- update new columns' values from corresponding rows in `charges_arc`
UPDATE `charges`
INNER JOIN `charges_arc` ON `charges`.`ChargeID` = `charges_arc`.`ChargeID`
SET `charges`.`ChargeClearDate` = `charges_arc`.`ChargeClearDate`
WHERE `charges`.`ChargeID` = `charges_arc`.`ChargeID`;
ChargeID
is indeed the Primary Key column in both charges
and charges_arc
tables.
This means that this statement does satisfy MySQL Workbench's https://dev.mysql.com/doc/workbench/en/workbench-faq.html#faq-workbench-delete-safe:
By default, Workbench is configured to not execute DELETE or UPDATE queries that do not include a WHERE clause on a KEY column.
Is there a solution to rewrite this query such that Workbench does not Error 1175, and which does not require setting SET SQL_SAFE_UPDATES=0
/changing Workbench's preferences?