Working on a query but I need to implement some if else logic to check for a loop but I keep getting a 1064 bad syntax error.
I've gone over the manual and some examples but still no luck. So I stripped down my query to the most basic comparison below:
SET @start_date = '2019-06-01';
SET @other_date = CURDATE();
IF @start_date < @other_date THEN
Select 'True';
ELSE
Select 'False';
END IF;
The below is the read out I receive from status:
SET @start_date = '2019-06-01' OK Time: 0.065s
SET @other_date = CURDATE()
OK Time: 0.065s
IF @start_date < @other_date THEN Select 'True'
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 'IF @start_date < @other_date THEN Select 'True'' at line 1 Time: 0.067s
I understand that I'm going wrong somewhere with my syntax on the IF clause but in the docs it states:
IF [condition] THEN if-statements ELSE else-statements; END IF;
I'm not sure why this is failing, any insight would be appreciated.