0

This is throwing a syntax error on the first SELECT - why?

CREATE DEFINER=`root`@`localhost` PROCEDURE `get_cand_by_pos_skill`(IN id INT)
BEGIN
SELECT *  FROM candidates 
WHERE cid = ANY(SELECT candid FROM positionskills p, candidate_skills s WHERE p.positionid = id and s.skillid = p.skill);
END
Raph117
  • 3,441
  • 7
  • 29
  • 50

1 Answers1

0
  • You need to define the Delimiter to something else (eg: $$) other than ;. At the end redefine back to ;
  • Please do not use comma based Implicit joins. These are obsolete and error-prone. Please switch to modern JOIN .. ON based syntax.
  • Switch to IN instead of = ANY:

Try the following instead:

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_cand_by_pos_skill`(IN id INT)
BEGIN

SELECT *  
FROM candidates 
WHERE cid IN (SELECT candid 
              FROM positionskills p 
              JOIN candidate_skills s ON s.skillid = p.skill
              WHERE p.positionid = id);

END $$
DELIMITER ;
Madhur Bhaiya
  • 28,155
  • 10
  • 49
  • 57