DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `psico`.`getExamQuestions`(vExamFk INT) BEGIN SELECT p.text,p.examFk,p.questionFk,p.answerFk,p.id ,a.text AS answerText,a.correct, a.id AS answerFk FROM psico.examView as p INNER JOIN psico.answer as a ON p.questionFk = a.questionFk WHERE examFk = vExamFk; END$$ DELIMITER ;