Trouble with <>

Hi all. I have a table, called tblRaces with fields ID, Event, Bikes, Bike_Shop, Bags, Event_IDFK. Event_IDFK is foreign key to contacts table where the athletes name is stored.

I have a query taken off of another temp table called qry_Temp with fields ID, SKU, Bikes, Bike_Shop, Bags, Customer_IDFK.

tblRaces has data:

ID     Event                       Bikes    Bike_Shop    Bags    Event_IDFK
1        Chattanooga           1          Steve's                          124
2         Louisville                 2          Joe's                1             47
3         Louisville                 1          Joe's                               24

qry_Temp has data:

ID       SKU                        Bikes     Bike_Shop   Bags     Customer_IDFK
1       Chattanooga            1           Steve's                           124
2        Louisville                  1           Steve's          1               32

I am trying to make another query to find the entry in qry_Temp that doesn't match tblRaces (ID 2)

I have tried numerous things, but can't find the answer. They all return all the entries in qry_Temp.

 In this case I ONLY want ID 2 from the query, where the Event =SKU but the IDFK is <>

SELECT qry_Temp.SKU, qry_Temp.Bikes, qry_Temp.Bike_Shop, qry_Temp.Bags, qry_Temp.Customer_IDFK
FROM qry_Temp, tblRaces
WHERE (((qry_Temp.SKU)=[tblRaces].[Event]) AND ((qry_Temp.[Customer_IDFK]) <> [tblRaces].[Event_IDFK]))

And I have tried

SELECT qry_Temp.SKU, qry_Temp.Bikes, qry_Temp.Bike_Shop, qry_Temp.Bags, qry_Temp.Customer_IDFK
FROM [qry_Temp] LEFT JOIN tblRaces ON [qry_Temp].[SKU] = tblRaces.[Event]
WHERE (((tblRaces.Event)=[qry_Temp].[SKU]) AND ((tblRaces.[Customer IDFK])<>[qry_Temp].[Customer IDFK]))
GROUP BY [qry_Temp].SKU, [qry_Temp].[Bikes], [qry_Temp].[Bike_Shop], [qry_Temp].[Bags], [qry_Temp].[Customer IDFK];

And..

SELECT qry_Temp.SKU, qry_Temp.Bikes, qry_Temp.Bike_Shop, qry_Temp.Bags, qry_Temp.Customer_IDFK
FROM [qry_Temp] LEFT JOIN tblRaces ON [qry_Temp].[SKU] = tblRaces.[Event]
WHERE (((tblRaces.[Customer IDFK])<>[qry_Temp].[Customer IDFK]))
GROUP BY [qry_Temp].SKU, [qry_Temp].[Bikes], [qry_Temp].[Bike_Shop], [qry_Temp].[Bags], [qry_Temp].[Customer IDFK];

HELP!
Steve BAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Terry WoodsIT GuruCommented:
select * from qry_Temp
where not exists 
  ( select * from tblRaces 
  where qry_Temp.SKU = tblRaces.Event
  and qry_Temp.[Customer_IDFK] = [tblRaces].[Event_IDFK]
  )

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve BAuthor Commented:
Thank You Terry, That looks like a winner!  And FAST too!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.