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!

Extracting Alt Contact Emails Only

Status
Not open for further replies.

VTWP

Technical User
Mar 15, 2006
2
0
0
US
I am using an sql query I found to get the alt contact emails but it also gives me the primary contact emials. Could anyone tell me how to tweak it?

select contact1.company,contact1.contact,
contsupp.address2 as EM_Contact,
contsupp.contsupref,
contsupp.zip from contsupp join contact1
on contact1.accountno=contsupp.accountno and
contsupp.contact = "E-mail Address"
order by contact1.company


Thanks,
Worth
 
if you do not want the primary contact emails then the ZIP field in the contsupp table should equal 0011

Also a note of warning the contsupref fields only stores the first 35 characters of the email address, if you have an address longer then this then the rest would be put into the address1 field... so i have edited the sql for you

This shows you the email address that are not primary

Code:
select contact1.company,contact1.contact,
contsupp.address2 as EM_Contact,
contact1.accountno,
contsupp.contsupref + contsupp.address1 as Email,
contsupp.zip from contsupp join contact1
on contact1.accountno=contsupp.accountno and
contsupp.contact = "E-mail Address" and contsupp.zip = "0011"
order by contact1.company

The sql code below shows you the primary email addresses only.

Code:
select contact1.company,contact1.contact,
contsupp.address2 as EM_Contact,
contact1.accountno,
contsupp.contsupref + contsupp.address1 as Email,
contsupp.zip from contsupp join contact1
on contact1.accountno=contsupp.accountno and
contsupp.contact = "E-mail Address" and contsupp.zip = "0011"
order by contact1.company

If you require all the email address then just take out the " and contsupp.zip = "0011" from the sql code.

I hope this helps it not then let me know.
 
Thanks M8KWR. I think you posted the exact same two scripts from what I can tell but I get it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top