View Full Version : 'Not Like' query removing all results


noboffinme
11-11-2009, 11:09 PM
Hello

I am writing a query where I have to exclude a set of id numbers located in a previously created query.

I have two tables - Sheet1 & Sheet2.

Each has 2 fields - id_number & Product

So my logic is to add a line in the Access Query Builder as follows;

In the id number field of this second query, I have added a line to select only records not equal to this first query, here's what I mean.

The Criteria line in the Query builder for the field [Sheet2]. has this script added -

<> [Sheet1].[id_number]

I have also used 'Not Like' instead of '<>' but get the same result.

What's happening is I get [I]NO results for this query when my test data should show some results.

Somehow, I am filtering out all the data??

Anyone aware of what I'm doing wrong?

Thanks in advance, : )

namliam
11-11-2009, 11:17 PM
What you are looking for is an Unmatched query, use the access wizard to build it :)

noboffinme
11-13-2009, 09:21 AM
Thanks namliam

I found after doing this that I could check the design view of the query builder for the correct design to achieve the answer & note this in future.

The correct design for the query builder was to place an outer join on the table I wanted to exclude through the id field.

Then instead of putting the condition "<> [Sheet1].[id_number]" on the [Sheet2].[id_number] field in the Query builder, it was best to add the "[Sheet1].[id_number]" to the query design separately & apply the condition 'Is Null'.

Thanks for the response, Cheers : )