If condition is used for decision making purpose. If condition check Boolean value, if the condition is true then statement under if condition is executed or else controls goes to else part execute this statement.
You can have more multiple if condition with else statement in a single query. If statement can be written under store procedures , function, Trigger, query for decision making purpose.
Below is the picture real view of if condition.
1)Below is the syntax of if condition.
3)Here is the example of if condition with multiple if.
You can have more multiple if condition with else statement in a single query. If statement can be written under store procedures , function, Trigger, query for decision making purpose.
Below is the picture real view of if condition.
1)Below is the syntax of if condition.
IF condition {...statements to execute when condition is TRUE...} [ ELSE {...statements to execute when condition is FALSE...} ]
2)Below is the example of if condition.
Declare
@myValue INT=10
IF
(@myValue
<
25)
PRINT
'Value_1';
ELSE
PRINT
'Value_2';
3)Here is the example of if condition with multiple if.
Declare
@myValue INT=10
IF
(@myValue
=10)
PRINT
'Value
10';
ELSE
IF
(@myValue
=15)
PRINT
'Value
15';
ELSE
IF
(@myValue
=20)
PRINT
'Value
20';
ELSE
IF
(@myValue
=22)
PRINT
'Value
22';
ELSE
PRINT
'Value_2';
No comments:
Post a Comment