- Jun 24, 2004
- 343
- 0
- 0
Need to create a query as above. How can I do this in DB2?
My thought is:
SELECT not exists (select * from table) as answer;
But that doesn't work. The only other thing I can think of is something along the lines of:
select 'true' as answer
from t
where c=999 and 5 in (1,2,3)
union
select 'false' as answer
from t
where c=999 and 5 not in (1,2,3);
(NB: t is a table that has one entry where c=999)
But something similar (using exists, not exists) for my query above seems like a real hack.. and I think there should be a better way to accomplish this.
Thanks..
My thought is:
SELECT not exists (select * from table) as answer;
But that doesn't work. The only other thing I can think of is something along the lines of:
select 'true' as answer
from t
where c=999 and 5 in (1,2,3)
union
select 'false' as answer
from t
where c=999 and 5 not in (1,2,3);
(NB: t is a table that has one entry where c=999)
But something similar (using exists, not exists) for my query above seems like a real hack.. and I think there should be a better way to accomplish this.
Thanks..