I got the same problem when updating Openemr. My database is using mysql.
Error message as below.
ERROR: query failed: UPDATE
revision = (SELECT MAX(
revision) from icd10_dx_order_code) WHERE
dx_code = ‘U071’
Error: Table ‘icd10_dx_order_code’ is specified twice, both as a target for ‘UPDATE’ and as a separate source for data
I tried Mark solution but it seems like it did not work by making changes to patch.sql
Please follow up.