MySQL server version for the right syntax to use near '' at line
I found similar problems but they always were in php.
CREATE TRIGGER PL_gl BEFORE INSERT ON Zaznam_o_vstrel_br for each row BEGIN IF (NEW.Autor_branky IS NOT NULL) then UPDATE hrac SET Pocet_golu = Pocet_golu + 1 WHERE ID_num = NEW.Autor_branky; /*ERROR HERE*/ END IF; END;
I made so much modifications that I already don't know how is it correct.
create table hrac ( ID_num INT AUTO_INCREMENT Primary key, Jmeno VARCHAR (50) NOT NULL, Jmeno_tymu VARCHAR (50) NOT NULL, Datum_narozeni DATE, Domovsky_klub VARCHAR (50), Cislo_dresu INT, Pocet_golu INT);
Error says 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 9. That doesn't tells me anything so I tried at least 20 combinations. And in SQL it worked without any problem.
Assuming the SQL is correct, here is what I believe is going on. In your begin... end statement, you have statements that end in semicolons, and it hits the one on line 9, and it thinks you've finished defining the trigger. The trigger at that point isn't defined with correct syntax, so it fails. Try defining a new delimiter this before your first statement:
Then, instead of putting a semicolon after your END statement, use the new delimiter:
That will enable you to use semicolons in your trigger without a syntax error.