• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 392
  • Last Modified:

PROCEDURE in mysql

this is the first time i write. this is the example that i am use it but i have error  

CREATE PROCEDURE `kfupm`.`procedure1` ()
BEGIN
  select fname, lname, count(horseid) horses
  from Owner, Owns
  where Owner.ownerId = Owns.ownerId
  group by Owns.ownerId
  having count(horseId) > 2

END

how can i solve the error ?
0
mohannad399
Asked:
mohannad399
  • 2
2 Solutions
 
mankowitzCommented:
DELIMITER $$

DROP PROCEDURE IF EXISTS `kfupm`.`procedure1` $$
CREATE PROCEDURE `kfupm`.`procedure1` ()
BEGIN
  select fname, lname, count(horseid) horses
  from Owner, Owns
  where Owner.ownerId = Owns.ownerId
  group by Owns.ownerId
  having count(horseid) > 2;
END $$

DELIMITER ;
0
 
Meir RivkinFull stack Software EngineerCommented:
try:

DELIMITER // [1]
CREATE PROCEDURE `mysql`.`simpleproc4` (OUT param1 INT)
BEGIN
  select fname, lname, count(horseid) horses
  from Owner, Owns
  where Owner.ownerId = Owns.ownerId
  group by Owns.ownerId
  having count(horseId) > 2;
END
0
 
Meir RivkinFull stack Software EngineerCommented:
change the mysql`.`simpleproc4 to your db and procedure name
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now