We help IT Professionals succeed at work.

Trouble with <>

Steve B
Steve B asked
on
85 Views
Last Modified: 2017-03-12
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!
Comment
Watch Question

Web Developer, specialising in WordPress
CERTIFIED EXPERT
Most Valuable Expert 2011
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Thank You Terry, That looks like a winner!  And FAST too!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions