2017-03-20 121 views
0
select OD.orderID, C.CustomerName, O.OrderDate,   
    round(sum(P.Price*OD.Quantity)) as TotalPrice 
inner join OrderDetails as OD on OD.OrderID=O.OrderID 
inner join Products as P on OD.ProductID=P.ProductID 
inner join Customers as C on O.CustomerID=C.CustomerID 
group by OD.OrderID 
Order by TotalPrice 
limit 5 

這是我的SQL語句。它給我'內在'的語法錯誤... 我可以問問題是什麼?SQL ERROR「1 near'inner',Syntax Error」W3C sample database

回答

5

你的SQL語句缺少FROM條款:

select OD.orderID, C.CustomerName, O.OrderDate,   
    round(sum(P.Price*OD.Quantity)) as TotalPrice 
FROM <your driving table here> 
inner ... 

想必,你想從Orders選擇:

select OD.orderID, C.CustomerName, O.OrderDate,   
    round(sum(P.Price*OD.Quantity)) as TotalPrice 
FROM Orders as O 
inner ... 
+0

啊對,感謝這表明,我的壞。 –

相關問題