The SQL query language supports if/else statements just like most programming languages, and in a similar fashion.
Example:
IF [Condition]
BEGIN
[Statement]
END
ELSE
BEGIN
[Statement]
END
The main difference is that instead of using the curly brackets – { and } – BEGIN and END satatements are being used.
Following the same flow, an if/else if/else statement looks like this:
IF [Condition]
BEGIN
[Statement]
END
ELSE IF
BEGIN
[Statement]
END
ELSE
BEGIN
[Statement]
END