I am trying to nest an if statement in what will eventually become a routine.
SET @foo = (SELECT foo FROM table WHERE id = 1);
SET @bar = (SELECT bar FROM table WHERE id = 1);
IF @foo = @bar THEN SET @thisVar = 1;
ELSE SET @thisVar = 0;
END IF
SELECT @thisVar;
但我得到:
Error Code: 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 @foo = @bar THEN SET @thisVar = 1; at line 1)
我做了什么错误?