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!

Pull from Two Tables 1

Status
Not open for further replies.

rbyrne1

MIS
Jun 12, 2008
7
US
I have two tables as follows:

CUSTOMERS
customernum
customername

ORDERS
ordernum
customernum
partnum

"SELECT customers.customernum, customername, ordernum FROM customers, orders WHERE partnum=123 and customers.customernum=orders.customernum"


I'm trying to pull a recordset of all customers that ordered part #123. The problem is that if a customer ordered three parts, one of which was #123, it's going to pull three records (one record for each . All I want is the single order number for the order that contains this part number.

I would think this would be an easy thing to do, but I'm all out of ideas.
 
Use the keyword distinct to get rid of duplicates in your output.

Code:
SELECT DISTINCT customers.customernum, customername, ordernum FROM customers, orders WHERE partnum=123 and customers.customernum=orders.customernum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top