locations、items、の 3 つのテーブルを持つ DB2 データベースがあります movement_history。テーブルにはへのitems外部キー があります。このテーブルには、外部キー 、into 、および 2 つの外部キーand 、 into があります。location_idlocationsmovement_historyitem_iditemslocation_id_beforelocation_id_afterlocations
location行がない場合、itemsまたはそれを参照していない場合は、削除したいと思いmovement_historyます。location行がどこかで参照されている場合は、更新して削除済みとしてマークしたいだけです。これを1つのステートメントで行う方法はありますか?これを行う最善の方法は何ですか?