大家好,这是我的下列情况
查询1:
select part_no, contract, vendor_no
from PURCHASE_PART_SUPPLIER_TAB
where part_no in (select distinct(part_no)
from IC_PARTS_FILE_TAB
) and
contract = '42';
输出1:
合同(网站)表
查询2:
从site_tab中选择合同作为网站;
输出2:
答案 0 :(得分:1)
这是我对你的要求的解释
尝试:
INSERT INTO PURCHASE_PART_SUPPLIER_TAB
(vendor_no, part_no, contract)
SELECT vendor_no, part_no, st.contract
FROM
PURCHASE_PART_SUPPLIER_TAB ppst
CROSS JOIN
SITE_TAB st
WHERE ppst.contract = '42'
AND part_no IN (SELECT part_no FROM IC_PARTS_FILE_TAB)
AND st.contract<>ppst.contract -- don't bother joining to master
AND NOT EXISTS
( SELECT *
FROM PURCHASE_PART_SUPPLIER_TAB
WHERE vendor_no = ppst.vendor_no
AND part_no = ppst.part_no
AND contract = st.contract
)