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

Distinct Values (Not sure what to search for)

Status
Not open for further replies.
Nov 16, 2006
19
0
0
GB
Have a query that i want to build but am not sure of the terminology to search for so I will attempt to describe the problem:

I have two tables

tbl_Names
Name
Andrew
Simon
Barry

tbl_Records
Name|Product
Andrew|Apple
Andrew|Banana
Simon|Pinecone
Barry|Apple
Simon|Apple
Dave| Apple
Dave| Sunflower
Ted| Coffee


I need a query that will return only distinct values from "tbl_Records" column "Name" which do not appear in "tbl_Names".

So if you ran it on the above you would come out with:

qry_Names
Distinct_Name
Dave
Ted


Hope that made sense and apologies if this is on here already but like i said above, i have no idea what terminology i want to search for.

Thank you in advance,
MD
 
Code:
Select R.Name As [Distinct Name]

From tblRecords As R LEFT JOIN tblNames As N
     ON R.Name = N.Name

Where N.Name IS NULL
 
Thanks a lot once again Golom.

It was returning:

Dave
Dave
Ted

But adding "DISTINCT" after the SELECT worked just fine.

Also defining tables as easier to write letters "tblRecords As R" is a neat way of doing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top