Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exclude data through a SQL Statment in a Query 1

Status
Not open for further replies.

work4livinsean

Programmer
Mar 28, 2006
23
US
Hey everyone,
I am having a problem with a simple SQL Statement. I found something that worked on another thread but when I tried it it did not work. What I am trying to do here is exclude some data from a query by matching up the ApexID's. Here is the SQL Statement:

SELECT queSubmit.Name, queSubmit.ApexID, queSubmit.Number, queSubmit.Okay
FROM tblExclude RIGHT JOIN queSubmit ON tblExclude.Apex_ID = queSubmit.ApexID
WHERE(((queSubmit.[ApexID])<>[tblExclude]![Apex_ID]));

The 'WHERE' statement is what I am having trouble on. Instead of not including the data it simple does not bring up any data. Can anyone help or give me any suggestions? I appreciate your help. Thanks.

Link to the thread where I found a solution that works but not when I try it...
Thanks in advance!
 
Maybe you'll see the problem if you reformat it
Code:
SELECT queSubmit.Name, queSubmit.ApexID, queSubmit.Number, queSubmit.Okay
FROM tblExclude RIGHT JOIN queSubmit 
        ON tblExclude.Apex_ID [COLOR=red] =[/color] queSubmit.ApexID
WHERE      tblExclude.Apex_ID [COLOR=red]<>[/color] queSubmit.ApexID
The "ON" and "WHERE" clauses are in direct contradiction. The WHERE eliminates exactly those records that were selected by the ON clause.


[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Your right! I read something in the other thread that I posted the link to that said the tables/queries should be connected somehow. Well I did that and that was causing the problem. Thanks you.
 
You wanted this ?
SELECT queSubmit.Name, queSubmit.ApexID, queSubmit.Number, queSubmit.Okay
FROM tblExclude RIGHT JOIN queSubmit ON tblExclude.Apex_ID = queSubmit.ApexID
WHERE tblExclude.Apex_ID Is Null

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top