I am trying to figure out how do to a conditional Update else Insert, however I am having issue with my query and cannot find the issue. Any tips or help would be appreciated.
IF EXISTS (SELECT * FROM analytics WHERE visit_date="09-10-2019") THEN
UPDATE analytics
SET slug = "000aaa", visit_date="09-10-2019", visits="1", continent="NA", country="Canada", state="Quebec", city="Montreal"
WHERE visit_date="09-10-2019";
ELSE
INSERT INTO analytics (slug, visit_date, visits, continent, country, state, city)
VALUES ("000aaa","09-10-2019", "1", "NA", "Canada", "Quebec", "Montreal");
END IF;
Error : You have an error in your SQL syntax; it seems the error is around: 'IF EXISTS ( SELECT * FROM analytics WHERE visit_date = "09-10-2019") at line 1