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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subquery on same table problem

Status
Not open for further replies.

DaveTappenden

Programmer
Jan 16, 2002
21
0
0
I have a simple table containing transaction codes.
I need to produce a query listing transactions of a certain type eg "XYZ" where NO transaction of another type eg "ABC" exist anywhere else in the same table. I am trying to avoid using a lookup, but just can't work out the subquery syntax, as it must act on the same table.

 
Kinda confused...but I think this is near what you are looking for:

SELECT *
FROM Table
WHERE TransactionType="XYZ"
AND TableID NOT IN (SELECT TableID FROM Table WHERE TransactionType = "ABC")

Hope that helps...

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top