GoldMine SQL Query- Additional Contacts and Email Address with Email & Mail Merge Code

The following is a SQL Query that will display Additional Contacts with their Mailing Address, Email Address and the associated Email Merge Code and Mail Merge Code.

select c1.accountno, c1.key1,,, ac.state, ac.mergecodes, em.contsupref, em.mergecodes, substring(em.mergecodes,1,1) as CHECKED
from contact1 c1
join contsupp ac on c1.accountno=ac.accountno
join contsupp em on ac.recid=em.linkacct
where ac.rectype=’c’ and’E-Mail Address’ and c1.Key1=’CUSTOMER’