Oracle DELETE sql with JOIN doesn't work

后端 未结 2 1634
孤城傲影
孤城傲影 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.

    0 讨论(0)
  • 2021-01-26 04:33

    try this

    DELETE FROM
      fact_tab
    WHERE
      EXISTS
      (
        SELECT
          1
        FROM
          temp
        WHERE
          temp.col1 = fact_tab.col1 AND
          temp.col2 = fact_tab.col2 AND
          temp.col2 = fact_tab.col2
      )
    
    0 讨论(0)
提交回复
热议问题