检查mySQL是否正确
PHPmyAdmin 不断拒绝这个 mySQL,我非常确定它是正确的,实际上并不需要它运行,它的统一工作,只需提交,它对我来说看起来是正确的。
我得到的实际错误是
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 23
我尝试添加和删除; LIMIT 和 END 都没有帮助,我是不是很愚蠢?
CREATE PROCEDURE topFive(
IN PID VARCHAR(6),
IN CID VARCHAR(6)
)
BEGIN
SELECT `OrderItem`.`ProductID` , COUNT(*) AS `Popularity`
FROM `OrderItem`,
(
SELECT `Order`.`OrderID`
FROM `OrderItem`,`Order`
WHERE
(`Order`.`OrderID`=`OrderItem`.`OrderID`)
AND
(`OrderItem`.`ProductID`=PID)
AND
(`Order`.`CustomerID`!=CID)
) AS `ORDER_ID_TABLE`
WHERE (`OrderItem`.`OrderID` = `ORDER_ID_TABLE`.`OrderID`)
GROUP BY `OrderItem`.`ProductID`
ORDER BY `Popularity`
LIMIT 0,5
END
谢谢^_^
PHPmyAdmin keeps rejecting this mySQL im pretty sure its right and don't actually need it to run, its uni work and just have to hand in, it looks right to me.
the actual error I get is
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 23
I have tried playing with adding and removing ; to LIMIT and END nether of which help , were am I being stupid?
CREATE PROCEDURE topFive(
IN PID VARCHAR(6),
IN CID VARCHAR(6)
)
BEGIN
SELECT `OrderItem`.`ProductID` , COUNT(*) AS `Popularity`
FROM `OrderItem`,
(
SELECT `Order`.`OrderID`
FROM `OrderItem`,`Order`
WHERE
(`Order`.`OrderID`=`OrderItem`.`OrderID`)
AND
(`OrderItem`.`ProductID`=PID)
AND
(`Order`.`CustomerID`!=CID)
) AS `ORDER_ID_TABLE`
WHERE (`OrderItem`.`OrderID` = `ORDER_ID_TABLE`.`OrderID`)
GROUP BY `OrderItem`.`ProductID`
ORDER BY `Popularity`
LIMIT 0,5
END
thanks ^_^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须更改分隔符。至少在 MySQL 客户端中你这样做:
You have to change the delimiter. At least in the MySQL client you do this: