SELECT contactDetails.*, categories.catName as MainCat, subcategories.subCatDesc as subName
<cfif isDefined('arguments.zing') AND arguments.zing EQ 1>,titles.title</cfif>
<cfif isDefined('arguments.connectfull') AND arguments.connectfull EQ 1>
,countries.countryName
</cfif>
FROM
<cfif isDefined('arguments.zing') AND arguments.zing EQ 1>
(
</cfif>
(contactDetails
LEFT JOIN subcategories ON contactDetails.SubcatID = subcategories.subcatID)
RIGHT JOIN Categories ON subcategories.catID = Categories.catID
<cfif isDefined('arguments.zing') AND arguments.zing EQ 1>
)
</cfif>
<cfif isDefined('arguments.zing') AND arguments.zing EQ 1>
inner join titles on titles.titleID = contactDetails.titles
</cfif>
<cfif isDefined('arguments.connectfull') AND arguments.connectfull EQ 1>
inner join countries on countries.countryid = contactDetails.country
</cfif> |