Does enclosing your OR-ed condition into parenthesis change the execution plan? It certainly does change the queries logic, and I'm sure it returns the resultset you actualy wanted. In other words, I think your original query does not return rows that you actualy want!
select * from table a, table b
where a.pk = b.fk
and
(
(a.code = 'X' and b.val > 1)
or (a.code = 'Y' and b.val < 1)
)
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?