Oracleで次のクエリを実行しようとしていますが、ここで作成できません
user_id = 561 in x1_table
。クエリは次のようになります
delete from x1_table where id in (select id from y1_table where actual_id=123 )
and user_id of x1_table should not be a part of select owner_id from y1_table
delete x from x1_table x
where x.user_id = 123 and
x.id in (select id from y1_table where actual_id = 123 ) and
x.user_id not in ( select owner_id from y1_table );
両方のテーブルに共通の列「id」があるため、結合を使用してクエリをフレーム化できます
delete x from x1_table x join y1_table y
on x.id = y.id
where x.user_id = 789 and
y.actual_id = 123 and
x.user_id != y.owner_id;