View Full Version : Using <> Giving me Records it should not


Jamet1234
10-22-2007, 07:54 AM
I have a query that uses "<>" to find records that are not equal between 2 tables. The formula looks like this:

<> [tblWorkPerformed]![ID]

It works fine as long as there is only one record in tblWorkPerformed, but once I add a second record I get the records I dont want plus the records I do. The records I do what are there twice. I found how to only get single records of each, but it still desplays the records it should not. I tried a dummy database, and it does the same thing. Do I have something wrong or is this just not possible.

Thanks
Anthony

RuralGuy
10-22-2007, 08:06 AM
Have you tried letting the Query Wizard create a "Find Unmatched" query for you and see what the SQL looks like?

Jamet1234
10-22-2007, 08:21 AM
Rural Guy,

No. I have looked at the sql of my query though. It weird how it works as long as the table has only one record, but then does not once new records are added.

How do you make the wizard create an find unmatched I have never seen that?

RuralGuy
10-22-2007, 08:31 AM
Go to the Queries section of the Database window and press the New button and select the wizard you want.

Brianwarnock
10-22-2007, 08:32 AM
If you click queries, new, and select Unmatched query wizard it will lead you through the steps.

Brian

Jamet1234
10-22-2007, 11:13 AM
Thanks Guys

I guess I did not pay attention never saw that in the wizard list before. Still weird how it works perfect that way but not when I do it from design. It may be the syntax is <=> not <> at least that is how the wizard displayed it.

Thanks
Anthony

Pat Hartman
10-22-2007, 12:45 PM
The wizard does it differently. It creates a left join and then checks the "right side" table for a null in the join field. This is a query that you should examine so you can learn how it works.

EMP
10-22-2007, 05:48 PM
Still weird how it works perfect that way but not when I do it from design.

When two tables in a query are Not Joined by the = sign, each record in the first table is matched with each record in the second table.

That is why when tblWorkPerformed contains more than one records it returns more records than you would expect as they all fulfil the condition Table1.ID<>tblWorkPerformed.ID.

^