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

Queries AND and ORs 1

Status
Not open for further replies.

savbci

Technical User
May 8, 2003
2
IN
I am running a query.
I have a list of Products people have bought. I want to know information on two products. products 443 AND 444.
I want to know out the people that purchased these two products what else did they purchase in previous years.
my table columns is as follows.

Product number, Customer Number, Purchase code (Code 'R' Represents all products that were purchased this year, and Code A Represents all products that were purchased in previous years).

Product number 443 and or 444 will have a purchase code of R. I want to find out what else they purchases (which could be R or A).

If anyone can help that would be greatly appreciated!!!! Thanks.
 
Did you try in your criteria: 443 OR 444 this should give you all record that product code.

Good Luck
 
Try:

SELECT PRODUCTNUMBER FROM PURCHASETABLE WHERE CUSTOMERNUMBER IN (SELECT CUSTOMERNUMBER FROM PURCHASETABLE WHERE (PRODUCTNUMBER = 443 OR PRODUCTNUMBER = 444) AND PURCHASECODE = "R")

The red subquery will find all cutomers who purchased product 443 OR 444 THIS YEAR. Then the outer query returns all the products that those customers have purchased regardless of when it was purchased. Hope that helps!



Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top