Im trying to print something when a condition is true in MySQL. This is my code:
BEGIN
UPDATE president
INNER JOIN election ON president.pres_name = election.candidate
SET yrs_serv = yrs_serv + 4
WHERE election.winner_loser_indic = 'W'
AND election.election_year = (SELECT MAX(election_year) FROM election)
BEGIN
IF (yrs_serv > 4) THEN BEGIN PRINT "warning"
END
END
END
When I run this I get this error.
MySQL: #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 'BEGIN IF (yrs_serv > 4) THEN BEGIN PRINT "warning" END END END' at line 7
This is inside a procedure. I can't figure this out. The code works if I don't try to use the IF statement.
Aucun commentaire:
Enregistrer un commentaire