Categories: Contact, Email
Description: This returns all emails for a mergecode specified in the WHERE portion of the query between the percent signs for both primary and additional contact email addresses.
SELECT
c1.company
,cs.contact
,c1.address1
,c1.address2
,c1.city
,c1.STATE
,c1.zip
,c1.country
,cs1.contsupref AS Email
,cs1.mergecodes
,c1.accountno
FROM
contsupp cs (NOLOCK)
LEFT OUTER JOIN contsupp cs1
ON cs.recid = cs1.linkacct
LEFT OUTER JOIN contact1 c1
ON cs.accountno = c1.accountno
WHERE
cs.rectype = 'C'
AND cs1.rectype = 'P'
AND cs1.contact = 'E-mail Address'
AND cs1.mergecodes LIKE '%Put mergecode here between percent signs%'
UNION
SELECT
c1.company
,c1.contact
,c1.address1
,c1.address2
,c1.city
,c1.STATE
,c1.zip
,c1.country
,cs.contsupref AS AddContEmail
,cs.mergecodes AS AddlMergeCode
,c1.accountno
FROM
contact1 c1 (NOLOCK)
JOIN contsupp cs
ON c1.accountno=cs.accountno
WHERE
cs.mergecodes LIKE '%Put mergecode here between percent signs%'
AND cs.rectype = 'P'
AND cs.contact = 'E-mail Address'
AND cs.zip LIKE '_1__'
Bookmark:
These icons link to social bookmarking sites where readers can share and discover new web pages.