0
product
product_id
parent_product_id
product_details
product_id
percent
和父表:
parent_product
parent_product_id
description_1
parent_product_details
parent_product_id
percent
我需要的是邏輯從那裏不存在product_detail刪除(在..從parent_product_detail數據)
然後
插入到product_detail WHE重新當我執行這個
delete from product_details pd
where not exists
(select ppd.*
from parent_product pp,
parent_product pd,
product p,
parent_product_details ppd,
,product_details pd
where pp.parent_product_id = '172'
and pd.parent_product_id = ppd.parent_product_id
and ppd.parent_product_id = pp.parent_product_id
and pd.product_id = p.product_id -- this filter
)
/
rollback
/
1040 rows deleted
Roll Back Completed
不存在(從parent_product_details數據)
我的問題是,產品沒有任何產品的細節。所以在選擇的子查詢時/執行它顯示結果只有一個
select ppd.*
from parent_product pp,
parent_product pd,
product p,
parent_product_details ppd,
--,product_details pd
where pp.parent_product_id = '172'
and pd.parent_product_id = ppd.parent_product_id
and ppd.parent_product_id = pp.parent_product_id
--and pd.product_id = p.product_id -- this filter
我如何去從product_details刪除記錄不再出現在parent_product_details,然後用刀片添加新的進入不存在的邏輯是什麼?
我認爲這個問題是該產品不含任何product_details所以它刪除這麼多行 –