I tried this
x
(Select o.OrderId,o.CustomerID, p.ProductName
from OrderDetails od
inner join
Products p on od.ProductID = p.ProductID inner join
Orders o on od.OrderID = o.OrderID)
Inner join Customers c on c.CustomerID = o.CustomerID
I got this error message Error 1: could not prepare statement (1 near “(“: syntax error)
I also tried this and another error
Select *
From
(select od.OrderID,p.ProductID,p.ProductName
from Products p
inner join OrderDetails od
on p.ProductID = od.ProductID)
inner join
(select c.Country,c.CustomerID,o.OrderID
from Customers c
inner join Orders o
on c.CustomerID = o.CustomerID)
on o.OrderID = od.OrderID;
I got this error message Error 1: could not prepare statement (1 no such column: o.OrderID)
Advertisement
Answer
I”m not sure where those parentheses are coming from. The error message is pretty clear: Most select
statements do not start with an open paren.
This should do what you want:
Select o.OrderId, o.CustomerID, p.ProductName, c.Country
from OrderDetails od inner join
Products p
on od.ProductID = p.ProductID inner join
Orders o
on od.OrderID = o.OrderID Inner join
Customers c
on c.CustomerID = o.CustomerID