Reputation: 20560
I can't seem to figure out where this is coming from... MySQL give me a syntax error of an empty quote and gives me a line number that doesn't seem to be wrong at all. Worse still, deleting the loop the line number points to still gives me the same error, just with a different line number.
ERROR 1064 (42000) at line 13: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 39
Talk about unhelpful feedback from MySQL!
The code in question is a stored function, and I ran into this when trying to apply the answer to another question. The updated code is available here.
EDIT: @MarkByers, here's the function reduced as low as I could get it while still triggering the error:
DROP FUNCTION IF EXISTS months_within_range;
DELIMITER //
CREATE FUNCTION months_within_range(starts_at DATE, ends_at DATE, filter_range VARCHAR(255)) RETURNS TINYINT
BEGIN
SET @matches = 1;
IF @matches >= 1 THEN RETURN 1;
ELSE RETURN 0;
END//
DELIMITER ;
Upvotes: 2
Views: 122
Reputation: 26699
You are missing the END IF
IF @matches >= 1 THEN RETURN 1;
ELSE RETURN 0;
END IF;
And the reason RETURN IF(@matches >= 1, 1, 0);
works is because this is the IF function
, which is different from the IF statement
Upvotes: 1