The task is to have a query returning 0 if no rows are going to be returned if the condition is applied and 1 if there are going to be more than 0 rows. Preferably this query should be faster than just querying the table with the condition and limiting the query with 1 row in result set.
views:
30answers:
1
+1
A:
select case
when exists (
select *
from MyTable
where MyColumn = 23
) then 1
else 0
end as RowsExist
RedFilter
2010-10-15 22:41:17