I have the following stored procedure:
CREATE PROCEDURE `Get_Events_And_Deadlines_By_User`(IN `intervalStart` INT, IN `intervalEnd` INT)
BEGIN
IF (intervalStart != 0 AND intervalEnd != 0) THEN
SELECT 1 AS `test`;
ELSEIF (intervalStart != 0 AND intervalEnd = 0) THEN
BEGIN
SELECT 2 AS `test`;
IF ((SELECT FOUND_ROWS())=1) THEN
SELECT 3 AS `test`;
END IF;
END;
ELSE
SELECT 4 AS `test`;
END IF;
END
When I run call Get_Events_And_Deadlines_By_User(1,0)
I only get the select query with 2 as the result, the select inside the if statement is never returned. It seems like only the first select query that is encountered is being executed before the stored procedure is returned. Why is this? What can I do to fix this? I want the select query INSIDE the if statement to be the ONLY result when the if holds.