I have the SQL Server Select statement:
SELECT *
FROM Table
WHERE(ClientPlants = 621 AND Carriers = 226)
OR (Carriers = 226 AND ClientPlants IS NULL)
ORDER BY ClientPlants
Now problem is when the first is valid, it still executes the second clause after the 'or'. How do I make it so the second clause is only executed if the first clause fails?
As in, if there are no results found for where clause 1 (ClientPlants = 621 AND Carriers = 226), go to 2 (Carriers = 226 AND ClientPlants IS NULL). If there is a result for clause 1, return query and stop.
I tried to look into CASE statement but couldn't see how to add it to my code.
Thanks in advance!