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!

retrieving UNIQUE records

Status
Not open for further replies.

Cohen227

MIS
Oct 30, 2001
8
US
I have two tables, both with the same data types, and I am trying to map the two together. My problem is that I only want one match for each record in table 1, but there are several matches being made. So I am trying to find a way to retrieve only uniwue records from table 1.

My querry now looks like:
SELECT c.Company, c.product, c.ship, c.port, c.startdate, c.enddate, r.company, r.product, r.ship, r.port, r.startdate, r.enddate
FROM Competitors AS c, RCL AS r
WHERE ((c.season2=r.season2 Or r.season2="Y/R") And
(r.startdate < r.enddate) And
(c.product1=r.product1) And
(c.port=r.port1) And
(c.mapto=r.company));

I want to find a way so that the combination of c.Ship and c.StartDate is unique...Any ideas?
 
add distinct to the select statement. Like Select Distinct...
 
If you want the Ship and StartDate to be unique but still see the other fields, you'll need to do a group by on these two fields and then use aggregate functions (like Max or Min) on the other fields. This is instead of the using the Distinct keyword.

If you add Distinct to a select statement, it shows records where any of the fields are different.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top