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

Get distinct info from fields 1

Status
Not open for further replies.

evergreean

Technical User
Feb 15, 2006
68
US
For my Access 2000 database I am trying to fetch unique emails from two fields in one table.

Currently I have this in the table:
Code:
Name    OfficeEmail          HomeEmail
Jones   Jones@company.com    Jones@company.com
Baker   Baker@company.com    JBaker@earthlink.net
Dawson  Dawson@company.com    
Cooper  Cooper@company.com   TCooper@yahoo.com
Smith   Smith@company.com    Smith@company.com

I need distinct output like this:
Name Email
Jones Jones@company.com
Baker Baker@company.com
Baker JBaker@earthlink.net
Dawson Dawson@company.com
Cooper Cooper@company.com
Cooper TCooper@yahoo.com
Smith Smith@company.com

My attempt is not working:
Code:
select disinct officeEmail, name from tableOne
UNION ALL
select distinct homeEmail, name from tableOne;
 
Try this:
Code:
select name, officeemail as EmailAddress
from yourtable
union
select name, homeemail
from yourtable
where homeemail is not null
order by name, EmailAddress

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top