oracle SQL left join()或full out join()根据键排除记录

问题描述 投票:0回答:1

我想在一个表中排除记录,如果它出现在另一个表中(基于键)

我想删除第一个表中的记录:cust_recommendataion在第二个表中具有相同的(cust_id和product_id),第二个表中的不同对(cust_id和product_id)可能只是第一个表的一个子集'不同的一对(cust_id和product_id)第二个表中也有一些'(cust_id和product_id)'对可能是唯一的。

我有2个表1. cust_recommendataion:每个cust_id都有多个product_id


cust_id | product_id |秩


  1. cust_last_buy;每个cust_id都有多个product_id

cust_id | product_id |日期


我很想知道如何做到这一点的建议。使用left join()或full out join()或任何其他建议?谢谢!

sql oracle set left-join full-outer-join
1个回答
0
投票

使用Exist的一种可能的解决方案:

Delete from cust_recommendataion c
WHERE
    EXISTS (
        SELECT
           *
        FROM
            cust_last_buy
        WHERE
            cust_id = c.cust_id
             and 
            product_id = c.product_id
    )
© www.soinside.com 2019 - 2024. All rights reserved.