Trigger if else with between

Viewed 43

I am trying to update a table on a purchase event so a admin gets an task depending on what is purchased. the products have codes with an catagory range between them which makes it easy because its an small shop. anyway how would i make this code work?

BEGIN
    IF (NEW.ProductCODE BETWEEN 11 AND 19)  
        THEN  
            INSERT INTO PleskTBL ( `CustomerCODE`, `PleskCONTACT`, `PleskSTATUS`, `PleskACTION`)VALUES (new.CustomerCODE, 'Not Ready', 'Not Ready', '0');

    ELSE IF (NEW.ProductCODE BETWEEN 21 AND 29)  
        THEN  
            INSERT INTO FTPTBL ( `CustomerCODE`, `FTPUSER`, `FTPPASSWORD`, `FTPSTATUS`) VALUES (new.CustomerCODE, 'Not Ready', 'Not Ready', 'NOT Ready');
    END IF;
END;

it is returning:

MySQL reports: #1064 - There is something wrong in the syntax used at '' in line 10

Inside phpmyadmin

1 Answers

Believe it or not, the space between the ELSE IF is causing the trouble.

If I try the same way, with a similar trigger body as yours:

enter image description here

I see the same error:

enter image description here

Now remove the space from the ELSE IF:

enter image description here

Trigger is created:

enter image description here

Related