I'm trying a IF statement inside of SQL code but I'm getting a sintax error, SQL always mess up my thinking.
What I'm trying is set a COUNT inside of a VAR and them use this VAR to define a UPDATE or INSERT command, something like:
SELECT COUNT(id) INTO @id FROM table1;
IF @id > 0 THEN
UPDATE
ELSE
INSERT;
Help is always wellcome.