If Then Else is not working
Hi, I apologize for the true newbieness of this question, but I have read 3-4 different pages, am copying what they write verbatim, and still get errors when I execute on my MySqlWorkbench.
I want to execute one of two queries, in a StoredProc, depending on a user's setting.
MySQL version 5.7.23-23
IF (1=1) THEN
select 1;
ELSE
select 2;
END IF
And the "IF" is underlined in red, with the message, ""IF" is not valid at this position, expecting EOF, ALTER, ANALYZE, BEGIN, BINLOG, CACHE, ..."
(Note wrapping the block in an BEGIN and END does not change this message)
I have even tried this:
create procedure spTest()
IF (1=1) THEN
select 1;
ELSE
select 2;
END IF
Here, select 1; has the "1" underlined in red with the message, "Statement is incomplete, expecting ;"
Any thoughts? I just want to run the simplest of IF statements....if user setting is A, run select statement 1. if user setting is B, run select statement 2.
Many thanks,