Click here to Skip to main content
16,016,925 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Im creating a stored procedure in phpmyadmin, which get the event category list. The condition im using, im sending a parameter 'e_range' where i get the list on the basis of whatever i set the range on this parameter 3, 4 etc. but im getting an error in while executing this script:

#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 'e_range; else select category_id, category_name, category_thumb from category' at line 4

SQL
CREATE PROCEDURE `sp_category_list`(IN e_range int)
BEGIN
if(e_range != 0) then
    select category_id, category_name, category_thumb from category_list order by category_name limit e_range;
else
    select category_id, category_name, category_thumb from category_list order by category_name;
END if;
END$$


Now problem is that, this script working good in my localhost pc. but im getting these error on my webserver CPANEL's phpmyadmin. the MySQL keyword 'LIMIT' is not taking the value through parameter. or maybe not recognizing it. but when i remove this parameter from the select command and set the static number on this, it will work:
SQL
select category_id, category_name, category_thumb from category_list order by category_name limit 5;


now what is the procedure, so i will get the list through my given parameter.

Thank you :)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900