Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INNER JOINS 1

Status
Not open for further replies.

coldfused

Technical User
Jan 27, 2001
2,442
US
Guys I'm trying to pull data from 4 tables that match a URL paramater.

I canb get the data from 3 tables like this:
Code:
SELECT *
FROM (Orders INNER JOIN OrderItems ON Orders.OrderID = OrderItems.OrderItemOrderID)
INNER JOIN Members ON Members.ID = Orders.OrderMemID
WHERE Orders.OrderID = '#URL.OrderID#'

But when I try to match up the fourth table:
Code:
SELECT *
FROM (Orders INNER JOIN OrderItems ON Orders.OrderID = OrderItems.OrderItemOrderID)
INNER JOIN Members ON Members.ID = Orders.OrderMemID
INNER JOIN Products ON Products.ProductID = OrderItemProdID.ID
WHERE Orders.OrderID = '#URL.OrderID#'

It errors out. How do I INNER JOIN and pull data from 4 tables?

----------------------------------------
Florida Web Design
Orlando Web Hosting
Florida Coldfusion Hosting
 
normally when you ask for help with sql, you would need to tell people which database system you're using

however, this can only be microsoft access :)

you need to parenthesize your joins -- you did it for 3 tables, just keep parenthesizing as you add additional tables
Code:
SELECT [i]columns[/i]
  FROM (
       (
       Orders 
INNER 
  JOIN OrderItems 
    ON Orders.OrderID 
     = OrderItems.OrderItemOrderID
       )
INNER 
  JOIN Members 
    ON Members.ID 
     = Orders.OrderMemID
       )
INNER 
  JOIN Products 
    ON Products.ProductID 
     = OrderItemProdID.ID
 WHERE Orders.OrderID = '#URL.OrderID#'


rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts May 8 2005)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top