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
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:
- How to add primary key from multiple table as a foreign key in a table in sql server 2008?Best solution by stackoverflow.com
- How to convert my SQL query to MS Access query?Best solution by Stack Overflow
- What is the performance of INNER JOIN vs WHERE?Best solution by Stack Overflow
- How to do SQL inner queries through SQLAlchemy?Best solution by Stack Overflow
- How to write delete query with inner join?Best solution by codeproject.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.