![]() The third if checks if the value of the variable is orders then fetch the records from the orders table.įinally, the ELSE statement for any other value of the variable should get the records of employee’s salary paid table. A CASE and a chain of IF / ELSE IF statements is evaluated. If the value is employees then get the sto_employees records. Related IF/ELSE IF statements and WHEN clauses in a CASE should not have the same condition. if the value is products then retrieve the data from sto_products table. So, the scenario is to check the value of a variable (table_name). Just for showing that you may nest to many levels, I am gone further by using another nested IF statement. Going another level in NESTED IF statement Try different values for the variable by your own table names and replace in the SELECT statement as well for experiencing it yourself. There, we placed another condition to check. ![]() ![]() This is terminated by using the END keyword. ![]() You can see, inside the ELSE statement, the BEGIN keyword is used where another IF statement is placed (the nested IF).
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |