Is it possible to perform a dynamic SQL join?

ACCESS SQL: Multiple INNER JOIN?

  • Hi, I'm trying to join three tables using inner join clause, hooping from one to another, ShoppingCart>Shoes>Brand Shoes>Type Is this possible? Here the code of how I'm attempting to do it. Or do I need a linking table between Type and Brand? Error: "Syntax error in FROM clause." "Select SC.Order_ID, SC.sShoes_ID, S.sPrice, B.bBrandName, T.typeName FROM ((ShoppingCart SC INNER JOIN Shoes S U ON SC.sShoes_ID = S.sShoes_ID) INNER JOIN Brand B WHERE S.bBrandCode = B.bBrandCode) INNER JOIN Type T ON S.tTypeCode = T.tTypeCode WHERE SC.uUsername = '" & username & "';"

  • Answer:

    You have a couple of errors. Typo, WHERE in JOIN clause instead of ON. Also you don't need the ; at the end. The query should be like this (I removed the parenthesis and added some line breaks for readability): "Select SC.Order_ID, SC.sShoes_ID, S.sPrice, B.bBrandName, T.typeName FROM ShoppingCart SC INNER JOIN Shoes S ON SC.sShoes_ID = S.sShoes_ID INNER JOIN Brand B ON S.bBrandCode = B.bBrandCode INNER JOIN Type T ON S.tTypeCode = T.tTypeCode WHERE SC.uUsername = '" & username & "'"

Douglas P at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Hard to say for certain without knowing just what your table schema is, but it certainly possible in theory. Remember that the result of a join of two tables it itself a table, so that can be joined to a third and so on. However, you have a bit of a mix-up in your first join...you can either do an explicit join using JOIN...ON or an implicit one using WHERE. Either lose the JOIN or change the WHERE to ON.

TheMadProfessor

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.