I have two different forms of SQL condition clauses.
exists (select 1 from [table] where [conditions])
(select max(1) from [table] where [conditions]) is not null
I don't have DB2 to test this on. But I think it depends. The following statement:
select max(1) from (select 1 as i)t where i = 2
Produces different results on SQL Server (
null) and MySQL (1). If DB2 returns
1, then the statements are different. I would expect it to return
If it returns
null, then the two statements are the same in effect. However, the
max() statement is likely to perform less well than the
exists statement can stop at the first matching value.