I have a very basic IF statement written that will be a part of a trigger, but when I try to run the query I receive a syntax error:
IF (STR_TO_DATE('09/29/2017','%m/%d/%Y') > CURDATE() - INTERVAL 1 DAY) THEN
SELECT * FROM apikeys;
END IF;
This is the error I'm getting:
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 'END IF' at line 1
I'm using MySQL 5.6
UPDATE: I now understand that IF/THEN statements can only be stored in procedures like triggers and are unable to be executed in this manner normally. Is there any way of knowing a trigger will be successful before implementing the new code into a live system? This trigger specifically controls a text messaging queue that fires SMS through Twilio, so I really cannot afford to guess and check.
IF... THEN ....END IFis only usable in stored procedures, triggers, etc...CASE?