我有两个要合并的 sql 语句。我确信这可以使用某种连接命令来完成,但我不太擅长使用它们,所以我希望有人能从这里提供帮助。
我想从:
SELECT DISTINCT CLOCFILEOT.CKEVNHM2.EVLEV1 AS WOSFROM
FROM
CLOCFILEOT.CKEVNHM2,
(
SELECT DISTINCT CONCAT('0',CPJDDTA81.F4801.WADOCO) AS WOS
FROM
CPJDDTA81.F4801,
CPJDDTA81.F4102
WHERE
CPJDDTA81.F4102 .IBITM = CPJDDTA81.F4801.WAITM
AND CPJDDTA81.F4801.WASRST IN( '30', '45' )
AND CPJDDTA81.F4102.IBSRP4 IN( 'ECT' )
AND CPJDDTA81.F4801.WAMMCU = ' ECT001'
) SELECTEDWOS
WHERE
CLOCFILEOT.CKEVNHM2.EVLEV1 = WOS
AND CLOCFILEOT.CKEVNHM2.EVLAB1 = 'E500'
并从该列表中减去以下内容:
SELECT DISTINCT CLOCFILEOT.CKEVNHM2.EVLEV1 AS WOSTOSUBTRACT
FROM
CLOCFILEOT.CKEVNHM2,
(
SELECT DISTINCT CONCAT('0',CPJDDTA81.F4801.WADOCO) AS WOS
FROM
CPJDDTA81.F4801,
CPJDDTA81.F4102
WHERE
CPJDDTA81.F4102.IBITM = CPJDDTA81.F4801.WAITM
AND CPJDDTA81.F4801.WASRST IN( '30', '45' )
AND CPJDDTA81.F4102.IBSRP4 IN( 'CAB' )
AND CPJDDTA81.F4801.WAMMCU = ' STH001'
) SELECTEDWOS
WHERE
CLOCFILEOT.CKEVNHM2.EVLEV1 = WOS
我在 adodb vba 中这样做,它有时会限制使用的 sql 命令的类型。
提前致谢。