For example, there is such a request

SELECT 0 UNION SELECT 1 UNION SELECT <что либо (КОНСТАНТА) или НИЧЕГО по условию> 

That is, the request must return 2 or 3 entries. Tell me how.

Closed due to the fact that the essence of the issue is incomprehensible by the participants aleksandr barakin , Kromster , Denis , cheops , HamSter Nov 4 '16 at 8:16 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • If the condition is not met, the request will return 2 records. If executed - three. If the third query returns 0 or 1, use UNION ALL - Zufir
  • @Zufir what condition? - iRumba
  • <anything or NOTHING by condition> - well, this is the condition. WHERE something is there - Zufir
  • @Zufir, you are ready to offer a request, otherwise I do not understand what you mean - iRumba
  • 2
    UNION SELECT 2 WHERE @ConditionVariable=1 - like so. If there is no WHERE - what does “By condition” mean? - Zufir

1 answer 1

For example:

 SELECT 0 UNION SELECT 1 UNION SELECT 2 WHERE @ConditionVariable=1