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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to link 4 tables - getting syntax error

Status
Not open for further replies.

rgreiser

Programmer
Mar 12, 2003
6
US
Hi, I am a beginner to SQL. I am trying to write a VB .Net program to display data from the generic Northwind Traders database. I have a datagrid displaying the customer data, then I have another datagrid displaying fields from the Orders, Order Detail and Product tables. My problem is trying to get the last part of attaching the Product Name to the Part Number. Here is the syntax:

SELECT
Orders.CustomerID,
Orders.OrderID,
Orders.OrderDate,
[Order Details].OrderID as Expr1,
[Order Details].ProductID,
[Order Details].Quantity,
[Order Details].UnitPrice,
[Order Details].Discount,
Products.ProductName
FROM
Orders
INNER JOIN [Order Details) ON
Orders.OrderID = [Order Details].OrderID
INNER JOIN Products ON
[Order Details].ProductID = Products.ProductID

The syntax error I am getting is:
Syntax error (missing operator) in query expression 'Orders.OrderID = [Order Details].OrderID
INNER JOIN Products ON [Order Details].ProductID = Products.ProductID'.


I have no idea what operator is missing. Any help would be greatly appreciated.

Now, when I remove the Products table and last INNER JOIN, it works fine. Is there a limit on INNER JOINS?

And I apologize if this was not the correct forum for this question.

Thanks in advance,
Rhonda
 
You have a parenthesis where you should have a square bracket.

Code:
SELECT
 Orders.CustomerID,
 Orders.OrderID,
 Orders.OrderDate,
 [Order Details].OrderID as Expr1,
 [Order Details].ProductID,
 [Order Details].Quantity,
 [Order Details].UnitPrice,
 [Order Details].Discount,
 Products.ProductName
FROM
 Orders 
INNER JOIN [Order Details[red]][/red] ON
 Orders.OrderID = [Order Details].OrderID
INNER JOIN Products ON
 [Order Details].ProductID = Products.ProductID

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
My mistake. That is a typo not in the code I am writing. The original does have a right bracket. I retyped it because it is on another computer and I was feeling lazy not wanting to cut and paste it to a floppy or email it to myself. :)

Thanks,
Rhonda
 
Is there anything else in the query you are currently have that is not posted here? This looks perfectly fine to me.

To debug your problem run the query with join only on order details and products table (selecting only the corresponding columns) and see what you get.

Regards,
AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top