I'm trying to run a statement to this effect:
IF EXISTS (SELECT * FROM LeadCustomer WHERE FirstName = 'John' AND Surname = 'Smith') THEN
SELECT * FROM LeadCustomer WHERE FirstName = 'John' AND Surname = 'Smith';
ELSE
INSERT INTO LeadCustomer (Firstname, Surname, BillingAddress, email) VALUES ('John', 'Smith', '6 Brewery close, Buxton, Norfolk', 'cmp.testing@example.com');;
END IF;
and it throws the error:
ERROR: syntax error at or near "IF"
I found this question but the format suggested in those answers don't seem to work either. Was wondering if anyone could tell me why this isn't working?