1-- MySQL
2
3-- example
4DELIMITER $$ -- Changes delimiter to $$ so can use ; within the procedure
5CREATE PROCEDURE select_employees()
6BEGIN
7 select *
8 from employees
9 limit 1000; -- Use the ; symbol within the procedure
10END$$
11DELIMITER ; -- Resets the delimiter
12
13/* syntax:
14DELIMITER $$ -- Changes delimiter to $$ so can use ; within the procedure
15CREATE PROCEDURE <Your-procedure-name>(<argument1><argument2>...<argumentN>)
16BEGIN
17 <Code-that-stored-procedure-executes>; -- Use the ; symbol within the procedure
18END$$
19DELIMITER ; -- Resets the delimiter
20*/
1DELIMITER //
2
3CREATE PROCEDURE count_trainers_with_skill(IN description varchar(50))
4BEGIN
5SELECT Skill.Description ,count(Trainer.TrainerID) as NumOfTrainers
6FROM Trainer, Skill, CertifiedTrainer
7WHERE (Trainer.TrainerID=CertifiedTrainer.TrainerID) and CertifiedTrainer.SkillID = Skill.SkillID and Skill.Description =description group by Skill.Description ;
8END
9//
10DELIMITER ;
11
12/*Call for procedure with parameter*/
13CALL count_trainers_with_skill("Shampooing");