Bug #54055 IF ELSE syntax error
Submitted: 28 May 2010 6:21 Modified: 28 May 2010 8:06
Reporter: Alex Shapiro Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.21 OS:Windows (Vista)
Assigned to: CPU Architecture:Any
Tags: compiling, editor, ELSE, IF, if else, ifelse, MySQL, syntax, workbench

[28 May 2010 6:21] Alex Shapiro
Description:
tried to create a function which containd 

IF ELSE statement. 

How to repeat:
DECLARE number INT(1);
SELECT COUNT(0) INTO number FROM table WHERE.......

IF number > 0 THEN 
   RETURN 0;
ELSE IF another_number > 0
   RETURN 1;
END IF;

END <------- this is where the syntax error ocurs.... why??
[28 May 2010 6:46] Alex Shapiro
I avoided this problem by not using the ELSE IF statement:

IF number > 0 THEN 
   RETURN 'return something';
END IF;

IF another_number > 0 THEN 
   RETURN 'something else';
END IF;
[28 May 2010 8:06] Susanne Ebrecht
http://dev.mysql.com/doc/refman/5.1/de/if-statement.html

IF search_condition THEN statement_list
    [ELSEIF search_condition THEN statement_list] ...
    [ELSE statement_list]
END IF

The correct syntax would be "elsif" and not "else if"