Tag Info

New answers tagged

1

You are using a selfie-selfie (SELF JOIN within a SELF JOIN). Queries that do self joins in the middle of UPDATEs and DELETEs can have unpredictable results because of two possibilities: rows not to be deleted when it should have been deleted rows deleted that were not meant to be deleted I wrote about this quirky behavior 3 years ago : Problem with ...


1

It may be due to unnecessary full materialization of the self-join. The only reason you are using T2 is to check that there is a lower DocumentID than the one you've gotten from T1. But if there are 100 such, the join will have 100 rows for the same v_user_id/T1.DocumentID. That's not necessary. Try to rewrite as ... AND EXISTS ( SELECT * FROM ...


1

Try removing the nesting levels, mysql can not delete from a table that's referenced as a child, instead there's a propriety trick like: DELETE t1.* FROM regulatory T1 JOIN regulatory T2 ON t1.group_ID=v_user_id AND t2.group_ID=v_user_id AND TRIM(t1.title)=TRIM(t2.title) AND TRIM(t1.spare1='red.gif') ...



Top 50 recent answers are included