Solved

MS Access Query  - Help with <> in query

Posted on 2014-07-27
2
309 Views
Last Modified: 2014-07-27
I have data that looks like this (simplified):

ID, Category
1,AB
2,CD
3,       <-- Blank or Null
4,EF
5,GH
6,AB
... 

Open in new window


When I try to filter out "GH" the query is also ignoring the Blank or Null rows. Here is the query:
SELECT ID, CATAGORY
FROM TestTable
WHERE CATAGORY <> "GH";

Open in new window


I have also tried this with the same results:
SELECT ID, CATAGORY
FROM TestTable
WHERE Not(CATAGORY = "GH");

Open in new window


I am at a loss why the results include all Categories except for "GH" (expected) and blank or null rows. This is omitting several thousand records that should be part of the results.
0
Comment
Question by:ckelsoe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
chaau earned 500 total points
ID: 40223200
It is a "normal" behaviour that applies to most databases. I could not find any "official" source from MSDN that is applicable to MS Access, here is a technical note applicable to SQL Server
There are two ways to fix this:
You can use a Nz function, like this:
SELECT ID, CATAGORY
FROM TestTable
WHERE Nz(CATAGORY, "") <> "GH";

Open in new window

Or you can add a condition for IsNull()
SELECT ID, CATAGORY
FROM TestTable
WHERE CATAGORY <> "GH" Or IsNull(CATEGORY);

Open in new window

0
 

Author Closing Comment

by:ckelsoe
ID: 40223445
Thanks - I forgot that. Query works as intended now.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question