gpt4 book ai didi

sql - EXCEPT 子句的 Access 替代

转载 作者:行者123 更新时间:2023-12-01 17:22:51 29 4
gpt4 key购买 nike

如何才能获得与在 ms access 中使用下面的 SQL 代码获得的相同结果?它无法识别 EXCEPT 子句...

SELECT DISTINCT 
P.Name,
T.Training
FROM Prof AS P,
Training_done AS TC,
Trainings AS T
WHERE (P.Name Like '*' & NameProf & '*')
AND (P.Primary_Area = T.Cod_Area)
EXCEPT
SELECT DISTINCT
P.Name,
T.Training
FROM Prof AS P,
Training_done AS TC,
Trainings AS T
WHERE (P.Name Like '*' & NameProf & '*')
AND (P.Cod_Prof = TC.Cod_Prof);

提前致谢!

最佳答案

为了摆脱 EXCEPT,您可以组合条件并否定第二个条件:

SELECT DISTINCT 
P.Name,
T.Training
FROM Prof AS P,
Training_done AS TC,
Trainings AS T
WHERE ((P.Name Like '*' & NameProf & '*') AND
(P.Primary_Area = T.Cod_Area))
AND NOT ((P.Name Like '*' & NameProf & '*') AND
(P.Cod_Prof = TC.Cod_Prof));

关于sql - EXCEPT 子句的 Access 替代,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15980525/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com