Skip to content
Advertisement

Avoiding IF statement to control WHERE statement

I have the below code which works and does what it needs to.

However, I need to manage two exact queries through an IF statement.

Can anyone see a way to do away with the IF ?

Advertisement

Answer

You can combine the queries using AND/OR logic which is essential knowledge for SQL queries. The following shows how to do this (untested – but should give you enough to go on):

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement