在访问数据库查询中未提供所需的输出

时间:2013-12-02 17:19:08

标签: ms-access

在我的Access数据库中,我有三个(PERS,QUALIFICATION,WORKED)表,KNO是一个公共字段。 我的代码在

之下
SELECT
    Pers.KNO, Pers.Name, Pers.Company
FROM
    (Pers LEFT JOIN Qualification
    ON Pers.KNO = Qualification.KNO)
    LEFT JOIN Worked
    ON Pers.KNO = Worked.KNO
WHERE
        (((Qualification.Qualification)="CCNA")
    AND ((Qualification.Grade)="A"))
    and ((Pers.Company not like 'IMDT*')
    and ( Pers.Company not like 'MZIN*'))
    and ((Worked.Company not like 'IMDT*')
    and ( Worked.Company not like 'MZIN*'))
GROUP BY Pers.KNO, Pers.Name, Pers.Company;

所有行都按预期工作但是这一行 and ((Worked.Company not like 'IMDT*') and ( Worked.Company not like 'MZIN*')) 没有提供正确的输出。根据我的代码,在名为IMDT或MZIN的公司工作的人不应该反映在我得到的输出中。

但它们包含在输出中。我怎样才能纠正它?

1 个答案:

答案 0 :(得分:0)

SELECT Pers.kno,Pers.Name,Pers.Company FROM WORK LEFT JOIN(Pers LEFT JOIN qualified ON Pers.kno = qualification.kno)ON working.kno = Pers.kno WHERE(((working.Company)不喜欢“IMDT *”和(working.Company)不喜欢“MZIN *”)) GROUP BY Pers.kno,Pers.Name,Pers.Company HAVING(((Pers.Company)不喜欢“MZIN *”和(Pers.Company)不喜欢“MZIN *”));