Question : Ms-Access is a trouble to me!

i m trying to run the coldfusion query which have access database i am using joins, joins in acccess is a trouble

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
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>


but suppose currently i am not using the connectfull argument, so i will be skipping that country iiner join:

i am getting the following error:

[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Join expression not supported.

now suppose i have to join the connectfull argument too. what could be my query that should work in both cases.

Please guide me

Access have troubled me for joins from ages

Answer : Ms-Access is a trouble to me!

(no points please ...)

> but this would work in SQL Server

Yes, but Access is a real pain. It's not as smart as sql server. AFAIK it requires parenthesis when you have 3 or more tables to indicate how the JOINs should be evaluated.  

Assuming this combination of LEFT joins is even allowed in Access, something like the example below. You're best bet is to test it directly in Access first. Just to make sure the parenthesis are correct.

SELECT contactDetails.*
     , categories.catName as MainCat
     , subcategories.subCatDesc as subName  
     , titles.title
     , countries.countryName
FROM
(    (   (contactDetails
             left JOIN subcategories ON contactDetails.SubcatID = subcategories.subcatID )
             left JOIN Categories ON subcategories.catID = Categories.catID )
             left join titles on titles.titleID = contactDetails.titles )
             left join countries on countries.countryid = contactDetails.country

Random Solutions  
 
programming4us programming4us