Note: This code is written and intended for use in Microsoft Access and will not work in the SQL Server Query Analyzer.




SELECT

dbo_FUND.DESCRIPTION, dbo_AttributeTypes.DESCRIPTION,

dbo_AttributeTypes.TYPEOFDATA, dbo_FundAttributes.TEXT,

dbo_FundAttributes.NUM, dbo_FundAttributes.DATETIME,

dbo_FundAttributes.CURRENCY, dbo_FundAttributes.BOOLEAN,

dbo_TABLEENTRIES.LONGDESCRIPTION, dbo_RECORDS.FIRST_NAME,

dbo_RECORDS.LAST_NAME

FROM

((dbo_FUND INNER JOIN (dbo_FundAttributes INNER JOIN dbo_AttributeTypes ON

dbo_FundAttributes.ATTRIBUTETYPESID = dbo_AttributeTypes.ATTRIBUTETYPESID) ON

dbo_FUND.ID = dbo_FundAttributes.PARENTID) LEFT JOIN dbo_TABLEENTRIES ON

dbo_FundAttributes.TABLEENTRIESID = dbo_TABLEENTRIES.TABLEENTRIESID) LEFT JOIN

dbo_RECORDS ON dbo_FundAttributes.ConstitID = dbo_RECORDS.ID;



Because of the different data types, an attribute's value is stored in a different fields depending on the  data type.  You can use the ATTRIBUTETYPES.TYPEOFDATA to determine where the value would be stored in the FUNDATTRIBUTES table:



1 - Text - FUNDATTRIBUTES.TEXT

2 - Number - FUNDATTRIBUTES.NUM

3 - Date/Time - FUNDATTRIBUTES.DATETIME

4 - Currency - FUNDATTRIBUTES.CURRENCY

5 - Boolean - FUNDATTRIBUTES.BOOLEAN

6 - TableEntry - FUNDATTRIBUTES joined to TABLEENTRIES.LONGDESCRIPTION

7 - Constituent - FUNDATTRIBUTES joined to RECORDS.LASTNAME, RECORD.FIRSTNAME

8 - Fuzzy date - FUNDATTRIBUTES.TEXT stored in format YYYYMMDD

Disclaimer: We provide 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. Our 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.