Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Condition select with Union
Message
From
28/04/2014 10:27:31
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Condition select with Union
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01599171
Message ID:
01599171
Views:
61
I have a select which is conditional. So, basically, if it would only be that one, I would put that into a IF and only execute that SQL if the condition matches. However, when the condition matches, I need to include that with a Union. So, what is the best way to achieve that. Here is an example:
SELECT Client.Title FROM Client WHERE Client.NoProvince=22
 UNION
SELECT Client.Title FROM Client WHERE Client.NoProvince=23
So, basically, in some circumstances, the first select should not be considered.

Or, is simply putting that select into the first part of the IF and the smaller select in the Else would do?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform