\"." />
开发者

MS-Access query filters OK on "=" but not when I use "<>"?

I am using Microsoft Access 2000,

This query is filtering when I use "=" condition, but it is not filtering when i use "<>". What might be the problem?

SELECT tblRevRelLog_Detail.RevRelTrackingNumber, tblRevRelLog_Detail.PartNumber, tblRevRelLog_Detail.ChangeLevel, tblRevRelLog_Detail.Version, tblRevRelLog_Detail.JobPnType, tblRevRelLog_Detail.EdsName, tblRevRelLog_Detail.FmeaText1, tblRevRelLog_Detail.FmeaText2, tblRevRelLog_Detail.LasdtEvent, tblRevRelLog_Detail.DetailerNamePerPartNumber, tblRevRelLog_Detail.DetailerCompanyPerPartNumber
FROM tblRevRelLog_Detail LEFT JOIN tblEventLog ON tblRevRelLog_Detail.PartNumber = tblEventLog.PartNumber
WHERE (((tblEventLog.EventTypeSelected)<> 'Pn REMOVED from W开发者_如何学编程rapper'));


Why not try:

SELECT td.RevRelTrackingNumber,
       td.PartNumber,
       td.ChangeLevel,
       td.Version,
       td.JobPnType,
       td.EdsName,
       td.FmeaText1,
       td.FmeaText2,
       td.LasdtEvent,
       td.DetailerNamePerPartNumber,
       td.DetailerCompanyPerPartNumber
FROM   tblRevRelLog_Detail td
LEFT JOIN tblEventLog te ON td.PartNumber = te.PartNumber
WHERE NOT(((te.EventTypeSelected) = 'Pn REMOVED from Wrapper'));

Not much of an Access person, but I believe that would acheive what you want.


Maybe the column has null values? SQL (and hence, I suppose Access) uses three valued logic. There is true, false, and unknown. and NUll values are assumed unknown. So

WHERE col = 'value'

returns all rows where col is not null and has the value 'value'

WHERE col <> 'value'

returns all rows where col is not null and the value of col is not 'value'

WHERE col is null

returns all rows where col is null.

To return the rows that do not fulfill col = 'value', you will have to use

WHERE col is null OR col <> 'value'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜