Microsoft SQL Query:

SELECT

RECORDS.ORG_NAME AS 'ORGANIZATION',
RECORDS_1.FIRST_NAME + ' ' + RECORDS_1.LAST_NAME AS 'RELATIONSHIP NAME',
ADDRESS.ADDRESS_BLOCK, ADDRESS.CITY, ADDRESS.STATE, ADDRESS.POST_CODE, PHONES.NUM AS 'PHONE NUMBER',
TABLEENTRIES.LONGDESCRIPTION AS 'PHONE TYPE'

FROM

((RECORDS INNER JOIN CONSTIT_RELATIONSHIPS ON RECORDS.ID = CONSTIT_RELATIONSHIPS.CONSTIT_ID)
INNER JOIN RECORDS AS RECORDS_1 ON CONSTIT_RELATIONSHIPS.RELATION_ID = RECORDS_1.ID)
INNER JOIN ((((CONSTIT_ADDRESS INNER JOIN ADDRESS ON CONSTIT_ADDRESS.ADDRESS_ID = ADDRESS.ID)
LEFT JOIN CONSTIT_ADDRESS_PHONES ON CONSTIT_ADDRESS.ID = CONSTIT_ADDRESS_PHONES.CONSTITADDRESSID)
LEFT JOIN PHONES ON CONSTIT_ADDRESS_PHONES.PHONESID = PHONES.PHONESID)
LEFT JOIN TABLEENTRIES ON PHONES.PHONETYPEID = TABLEENTRIES.TABLEENTRIESID) ON RECORDS_1.ID = CONSTIT_ADDRESS.CONSTIT_ID

WHERE

RECORDS.IS_CONSTITUENT=-1 AND RECORDS.KEY_INDICATOR = 'O'

ORDER BY RECORDS.ORG_NAME


Microsoft Access Query:

SELECT

IIf([dbo_RECORDS].[KEY_INDICATOR]="I",[dbo_RECORDS].[FIRST_NAME] & " " & [dbo_RECORDS].[LAST_NAME],[dbo_RECORDS].[ORG_NAME]) AS Name, IIf(dbo_RECORDS_1.KEY_INDICATOR="I",dbo_RECORDS_1.FIRST_NAME & " " & dbo_RECORDS_1.LAST_NAME,dbo_RECORDS_1.ORG_NAME) AS [Relationship Name], dbo_ADDRESS.ADDRESS_BLOCK, dbo_ADDRESS.CITY, dbo_ADDRESS.STATE, dbo_ADDRESS.POST_CODE, dbo_PHONES.NUM AS [Phone Number], dbo_TABLEENTRIES.LONGDESCRIPTION AS [Phone Type]

FROM

((dbo_RECORDS INNER JOIN dbo_CONSTIT_RELATIONSHIPS ON dbo_RECORDS.ID = dbo_CONSTIT_RELATIONSHIPS.CONSTIT_ID) INNER JOIN dbo_RECORDS AS dbo_RECORDS_1 ON dbo_CONSTIT_RELATIONSHIPS.RELATION_ID = dbo_RECORDS_1.ID) INNER JOIN ((((dbo_CONSTIT_ADDRESS INNER JOIN dbo_ADDRESS ON dbo_CONSTIT_ADDRESS.ADDRESS_ID = dbo_ADDRESS.ID) LEFT JOIN dbo_CONSTIT_ADDRESS_PHONES ON dbo_CONSTIT_ADDRESS.ID = dbo_CONSTIT_ADDRESS_PHONES.CONSTITADDRESSID) LEFT JOIN dbo_PHONES ON dbo_CONSTIT_ADDRESS_PHONES.PHONESID = dbo_PHONES.PHONESID) LEFT JOIN dbo_TABLEENTRIES ON dbo_PHONES.PHONETYPEID = dbo_TABLEENTRIES.TABLEENTRIESID) ON dbo_RECORDS_1.ID = dbo_CONSTIT_ADDRESS.CONSTIT_ID

WHERE

(((dbo_RECORDS.IS_CONSTITUENT)=-1))

ORDER BY

IIf([dbo_RECORDS].[KEY_INDICATOR]="I",[dbo_RECORDS].[Last_NAME] & "," & [dbo_RECORDS].[First_NAME],[dbo_RECORDS].[ORG_NAME]);
 

Disclaimer: Blackbaud provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Structured Query Language and the tools used to create and modify SQL statements and Crystal Reports. Blackbaud Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.