所以我正在尝试制作一张桌子。我已经设置了所有代码,但是当我尝试查看数据库时,它给了我一个错误。
Syntax error (missing operatior) in query expression 's.SupplierID = p.SupplierID LEFT JOIN OrderDetails AS od
on p.ProductID = od.ProductID LEFT JOIN Orders AS o
on od.OrderID = o.OrderID LEFT JOIN Customers AS c
on o.CustomerID = c.CustomerI'
但是这里是完整的代码:
Select p.ProductName AS 'Out of Stock Product', o.OrderID, c.CompanyName, c.ContactName, c.Address + ' ' + c.City +', ' + IsNull(c.StateOrRegion+ ', ', '')+ c.Country+', ' + c.PostalCode AS 'ADDRESS'
From Suppliers AS s LEFT JOIN Products AS p
on s.SupplierID = p.SupplierID LEFT JOIN OrderDetails AS od
on p.ProductID = od.ProductID LEFT JOIN Orders AS o
on od.OrderID = o.OrderID LEFT JOIN Customers AS c
on o.CustomerID = c.CustomerID
Where Discontinued = 1
Order By p.ProductName
关于我哪里出错的任何想法?
编辑:所以我发现我应该在连接中添加括号,但现在它给了我另一个问题。
更新的代码:
Select p.ProductName AS 'Out of Stock Product', o.OrderID, c.CompanyName, c.ContactName, c.Address + ' ' + c.City +', ' + IsNull(c.StateOrRegion+ ', ', '')+ c.Country+', ' + c.PostalCode AS 'ADDRESS'
From (Suppliers AS s LEFT JOIN Products AS p
on s.SupplierID = p.SupplierID) LEFT JOIN
(OrderDetails AS od ON p.ProductID = od.ProductID) LEFT JOIN (Orders AS o
on od.OrderID = o.OrderID) LEFT JOIN (Customers AS c
on o.CustomerID = c.CustomerID)
Where Discontinued = 1
Order By p.ProductName
错误是:“JOIN操作中的语法错误”,所有大写的突出显示为“on”,方便您查看。
答案 0 :(得分:1)
所以这是最终的代码:
Select p.ProductName AS 'Out of Stock Product', o.OrderID, c.CompanyName, c.ContactName, c.Address, c.City , c.StateOrRegion, c.Country, c.PostalCode
From
(((
(Suppliers AS s LEFT JOIN Products AS p
on s.SupplierID = p.SupplierID) LEFT JOIN
OrderDetails AS od
on p.ProductID = od.ProductID) LEFT JOIN Orders AS o
on od.OrderID = o.OrderID) LEFT JOIN Customers AS c
on o.CustomerID = c.CustomerID)
Where Discontinued = 1
Order By p.ProductName
我必须添加括号'拉入'其他连接项。在访问中,我不能将多个列链接为一件事。 Derp de dur