This is my procedure:

     CREATE PROCEDURE sp_test_final6() 
    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 $$

I'm getting error :

 #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()
INSERT INTO `chef_ratings`( `chef_id`, `avg_t' at line 1 

Any idea why it is failing?

Edited: It works fine in mysql version 5.5 but in Server version: 4.1.22 it is giving this problem. How we can fix without upgrading?


1 Answer 1


I got the answer. Stored procedure supported in MYSQL since 5.0 .Older version doesn't support stored procedure .

reference link


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.