How to SELECT a column in a row and return another row if it doesn't exists? I want to write a query with two SELECT Statements in an order that if the first SELECT Statement doesn't return anything then only the second select statement runs.

SELECT col1 FROM MyTable WHERE col2=5


and if this doesn't return anything(there is no col2=5) then:

SELECT col3 FROM myTable WHERE col4=10


How should it be done?
Well this is incredibly inefficient and I fail to see the point, but...

IF EXISTS (SELECT 1 FROM ... WHERE ... &lt;1st clause&gt;)
BEGIN
  SELECT ... FROM ... WHERE &lt;1st clause&gt;;
END
ELSE
BEGIN
  SELECT ... FROM ... WHERE &lt;2nd clause&gt;;
END


Or if the types of col1 and col3 are compatible then...

SELECT ... FROM ... WHERE &lt;1st clause&gt;
UNION ALL
SELECT ... FROM ... WHERE &lt;2nd clause&gt;
  AND NOT EXISTS (SELECT ... FROM ... WHERE &lt;1st clause&gt;);


I don't know of any other way for SQL Server to determine there will be no rows from a query without actually running the query.