这是我的程序:
DELIMITER $$
CREATE PROCEDURE sp_test_final7()
BEGIN
INSERT INTO chef_ratings(`chef_id`,`avg_total_no_votes`,`avg_total_rating`,`no_of_votes`,`avg_rating`)
SELECT `chef_id`, (SELECT count(chef_id) FROM rates) / ( SELECT count(DISTINCT chef_id) FROM rates) ,
( ( SELECT sum( (`question_1` + `question_2` +`question_3` ) /3 ) FROM rates ) / ( SELECT count(chef_id) FROM rates) ),
( SELECT count(chef_id) FROM rates ),avg( (`question_1`+`question_2`+`question_3`) /3 )
FROM rates
GROUP BY `chef_id`;
END $$
DELIMITER ;
我收到错误:
#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 'PROCEDURE sp_test_final6()
BEGIN
INSERT INTO `chef_ratings`( `chef_id`, `avg_t' at line 1
知道它失败的原因吗?
编辑:它在mysql 5.5版中工作正常但服务器版本:4.1.22它正在解决这个问题。如何在没有升级的情况下修复?