E
E
easy_katka2020-11-22 12:24:13
MySQL
easy_katka, 2020-11-22 12:24:13

Why is mysql throwing error?

CREATE TRIGGER marketing_list_update
AFTER UPDATE
ON cms_offers
FOR EACH ROW
begin
if NEW.status = 'active' 
then UPDATE marketing_credits_requests SET sum_s=NEW.ammount, statut=NEW.status WHERE id_req=old.id;
else then UPDATE marketing_credits_requests SET  statut=NEW.status WHERE id_req=old.id;
end;

#1064 - 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 7

Did everything on mysql docks, version 5.5.25

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lazy @BojackHorseman MySQL, 2020-11-22
@easy_katka

24.3.1 Trigger Syntax and Examples
don't forget about DELIMITER

G
galaxy, 2020-11-22
@galaxy

The syntax for an IF block is:

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

You have then after else and no end if.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question