Delete with Left Join in Oracle 10g

前端 未结 5 1780
臣服心动
臣服心动 2020-12-05 19:33

I have the following code that works fine in MS SQL Server:

delete grp
from grp
left join my_data
on grp.id1 = my_data.id1
and grp.id2 = my_data.id2
and grp.         


        
5条回答
  •  清歌不尽
    2020-12-05 20:03

    If you want to ensure there is no ambiguity in what's being deleted, you could change Vincent's solution to:

    delete from grp where rowid in
        (
        select
             grp.rowid
        from
             grp left outer join my_data on
                grp.id1 = my_data.id1
            and grp.id2 = my_data.id2
            and grp.id3 = my_data.id3
            and grp.id4 = my_data.id4
        where
            my_data.id1 is NULL
        )
    

提交回复
热议问题