sql – 访问替代EXCEPT子句

前端之家收集整理的这篇文章主要介绍了sql – 访问替代EXCEPT子句前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在ms访问中获得与下面的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,Trainings AS T
 WHERE (P.Name Like '*' & NameProf & '*') 
   AND (P.Cod_Prof = TC.Cod_Prof);

提前致谢!

解决方法

为了摆脱除外,您可以结合条件并否定第二个:
SELECT DISTINCT 
       P.Name,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));
原文链接:/mssql/83869.html

猜你在找的MsSQL相关文章