SQL Learning Center - GoldMine

Use SQL queries to get answers from GoldMine

May 25, 2008

Contact Email with Specific Mergecode for Primary and Additional Contacts

by @ 10:43 am. Filed under MSSQL Email, MSSQL Contacts

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.

  1.  
  2. SELECT
  3.  c1.company
  4. ,cs.contact
  5. ,c1.address1
  6. ,c1.address2
  7. ,c1.city
  8. ,c1.STATE
  9. ,c1.zip
  10. ,c1.country
  11. ,cs1.contsupref AS Email
  12. ,cs1.mergecodes
  13. ,c1.accountno
  14. FROM
  15.  contsupp cs (NOLOCK)
  16.   LEFT OUTER JOIN contsupp cs1
  17.    ON cs.recid = cs1.linkacct
  18.     LEFT OUTER JOIN contact1 c1
  19.      ON cs.accountno = c1.accountno
  20. WHERE
  21.  cs.rectype = 'C'
  22.  AND cs1.rectype = 'P'
  23.  AND cs1.contact = 'E-mail Address'
  24.  AND cs1.mergecodes LIKE '%Put mergecode here between percent signs%'
  25. UNION
  26. SELECT
  27.  c1.company
  28. ,c1.contact
  29. ,c1.address1
  30. ,c1.address2
  31. ,c1.city
  32. ,c1.STATE
  33. ,c1.zip
  34. ,c1.country
  35. ,cs.contsupref AS AddContEmail
  36. ,cs.mergecodes AS AddlMergeCode
  37. ,c1.accountno
  38. FROM
  39.  contact1 c1 (NOLOCK)
  40.   JOIN contsupp cs
  41.    ON c1.accountno=cs.accountno
  42. WHERE
  43.  cs.mergecodes LIKE '%Put mergecode here between percent signs%'
  44.  AND cs.rectype = 'P'
  45.  AND cs.contact = 'E-mail Address'
  46.  AND cs.zip LIKE '_1__'
  47.  
Bookmark:

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Live
  • Google
  • Facebook
  • bodytext
  • StumbleUpon
  • Slashdot

Leave a Reply

You must be logged in to post a comment.

GoldMine SQL Tutorial:

General SQL Tutorials:

SQL Help Links:

Recommended Reading - SQL Books:

RSS:

Links:

Search For SQL Query:

GoldMine MS SQL Queries:

GoldMine dBase SQL Queries (LocalSQL):

22 queries. 0.089 seconds