我们被要求创建一个SQL语句来显示Rattlesnake Canyon Grocery在1997-01-01中所下订单的总订单金额。但是,ORDERS表与CUSTOMERS表不同。
所以这就是我所做的:
SELECT Orders.OrderID,
Orders.CustomerID,
Orders.EmployeeID,
Orders.OrderDate,
Orders.ShipperID,
Customers.CustomerID,
Customers.CustomerName,
Customers.ContactName,
Customers.Address,
Customers.City,
Customers.PostalCode,
Customers.Country
FROM Customers
INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID;
WHERE DATE = 1997-01-01
但是它向我展示了一个'错误'标志。如何解决这个问题?错误说:“无法准备”。
以下是数据库的链接:http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
答案 0 :(得分:1)
您忘记在date
添加引号并添加分号的错误位置。
SELECT Orders.OrderID,
Orders.CustomerID,
Orders.EmployeeID,
Orders.OrderDate,
Orders.ShipperID,
Customers.CustomerID,
Customers.CustomerName,
Customers.ContactName,
Customers.Address,
Customers.City,
Customers.PostalCode,
Customers.Country
FROM Customers
INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID //u added semicolon here which is wrong
WHERE DATE = '1997-01-01';
答案 1 :(得分:1)
您没有任何DATE列,请将 DATE列替换为 Orders.OrderDate 以及半列在错误的地方
SELECT Orders.OrderID,
Orders.CustomerID,
Orders.EmployeeID,
Orders.OrderDate,
Orders.ShipperID,
Customers.CustomerID,
Customers.CustomerName,
Customers.ContactName,
Customers.Address,
Customers.City,
Customers.PostalCode,
Customers.Country
FROM Customers
INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID
WHERE Orders.OrderDate= '1997-01-01';