我有错误
java.sql.SQLException:ORA-00933:SQL命令未正确结束
当我尝试执行以下SQL语句时。
在此声明中,当搜索客户名称时,应显示特定客户的所有租赁详细信息和反馈。 "查询"指用户在数据库中搜索名称(CustomerName)时的用户输入。
SELECT c.CustomerName, r.Rental_ID, r.Staff_ID, r.RentalDate, r.DueDate,
r.Customer_ID, f.Description
FROM Rental r, Customer c, FeedBack f
WHERE f.Customer_ID = r.Customer_ID
AND c.Customer_ID = f.Customer_ID
ORDER BY DueDate
WHERE CustomerName like "+ query +";
出了什么问题?
答案 0 :(得分:2)
因为您在错误的地方有WHERE
和ORDER BY
条款;不仅你在查询中实际上有两个WHERE
子句。它应该只有一个。首先应WHERE
,然后order by
。它应该是
WHERE CustomerName like "+ query +"
ORDER BY DueDate;
另外作为旁注,
JOIN
语法而不是旧式语法。您的查询应该是
SELECT c.CustomerName, r.Rental_ID,
r.Staff_ID, r.RentalDate,
r.DueDate, r.Customer_ID, f.Description
FROM Rental r
JOIN FeedBack f ON f.Customer_ID = r.Customer_ID
JOIN Customer c ON c.Customer_ID = f.Customer_ID
WHERE c.CustomerName like "+ query +"
ORDER BY r.DueDate;