Wanna Learn If-Else? - ByteScout

Wanna Learn If-Else?

When it comes to decision-making, there are always conditions on which decisions are formed. In other words, there are If-Else. From Assembly languages to modern languages, it-else is and was a very common part of them.

In real life also there are if-else when it comes to decision making if we take the example of the mindset of employees when it comes to getting a raise. He thinks, “if I got a good raise this year, I’ll stick to the same company, or else I’ll try to negotiate with management. If my negotiation succeeds, I’ll stick to the same company, or else I’ll join another company”. 🙂

Now, how to do this SQL Way. First of all, let’s see the syntax here

Here, we don’t need to specify the BEGIN-END block when we have only a single statement. But it’s good practice to have a BEGIN-END block. If we want to indicate the above example in SQL, we can write the below query here.

By the way, in my case output is ‘My Company is awesome!!’.


In conclusion, in SQL, the If Else statement is one of the most valuable queries that is used to make a decision. The If statement examines the situation first, and leaning upon the output of the first block, it will run the statements. So, when the trial situation in “If statement” is correct, then the query is written in the if code block will run. If not, then the code written in the Else block will be completed.


About the Author

ByteScout Team ByteScout Team of Writers ByteScout has a team of professional writers proficient in different technical topics. We select the best writers to cover interesting and trending topics for our readers. We love developers and we hope our articles help you learn about programming and programmers.