sql - oracle SQL left join() or full out join () exclude records based on keys
问题描述
I want to exclude the records in one table if it appear in the other table (based on keys)
I want to delete the record in the first table: cust_recommendataion which has the same( cust_id and product_id) in the second table the distinct pair of ( cust_id and product_id) in the second table may only a subset of the first table' distinct pair of ( cust_id and product_id) also there are some '( cust_id and product_id)' pair in the second table may unique.
I have 2 tables 1. cust_recommendataion: for each cust_id has multiple product_id s
cust_id | product_id | rank
- cust_last_buy ; for each cust_id has multiple product_id
cust_id | product_id | date
would love to know the suggestion how to do that. by using left join()or full out join()or any other suggestion? Thank you!
解决方案
一种可能的解决方案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
)
推荐阅读
- python - 在使用集合 Dijkstra Shortest Path Algorithim 的字典中删除给定节点时出现 KeyError
- node.js - 从不同文件夹执行节点 cli 应用程序时,dontenv(npm 模块)不加载正确的 .env 文件
- logging - 如何使用 NLog 直接记录到 Datadog
- wordpress - 如何正确扩展 Gutenberg 块核心/引用块?
- python - 在 Django TEMPLATES 中设置 DIRS url 时遇到问题
- wordpress - Wordress 通讯禁用重定向
- go - 加载样式表时找不到 GET 404
- javascript - 为什么我的反应原生 Firebase 登录不起作用?
- r - 使用 dplyr 在 R 中按组过滤数据框
- assembly - 在装配中消除 J 操作?