Oracle DELETE sql with JOIN doesn't work

后端 未结 2 1635
孤城傲影
孤城傲影 2021-01-26 03:35

My delete statement returns a 933 error in Oracle, I\'m not sure what is wrong-

DELETE b
from temp a
JOIN
  fact_tab b
on a.col1 = b.col1
and a.col2 = b.col2
and         


        
2条回答
  •  礼貌的吻别
    2021-01-26 04:12

    Oracle doesn't allow JOIN in a DELETE statement directly like that.

    You could do the delete in the following way:

    DELETE
    FROM fact_tab
    WHERE ROWID IN
      (SELECT b.rowid
      FROM temp a
      JOIN fact_tab b
      ON a.col1  = b.col1
      AND A.col2 = b.col2
      AND A.col3 = b.col3
      );
    

    You could also use WHERE EXISTS clause.

提交回复
热议问题