Great SQL Query - All Primary & Additional Contacts
Here's a handy SQL Query for you. It will show all primary and secondary contacts in the database. If the secondary contact has an address it'll display that address and if they don't it'll use the address information from the primary contact. To use go to:
Lookup | SQL Query then paste this into the box and hit query. I tested this on 6.7 SQL 2000 & 7.0 SQL 2005. It won't work on dBASE.
select company, contact, title, address1, address2, address3, city, state, zip, phone1, contact1.accountno from contact1
union
select contact1.company, contsupp.contact, contsupp.title, contact1.address1, contact1.address2, contact1.address3, contact1.city, contact1.state, contact1.zip, contsupp.phone, contact1.accountno from contact1, contsupp where rectype = 'C' and (contsupp.address1 is null or contsupp.address1 <= '') and contact1.accountno = contsupp.accountno
union
select contact1.company, contsupp.contact, contsupp.title, contsupp.address1, contsupp.address2, contsupp.address3, contsupp.city, contsupp.state, contsupp.zip, contsupp.phone, contact1.accountno from contact1, contsupp where rectype = 'C' and contsupp.address1 > ' ' and contact1.accountno = contsupp.accountno
order by company, contact




