Merging exists and not exists into one query - oracle magic
Posted
by stic
on Stack Overflow
See other posts from Stack Overflow
or by stic
Published on 2010-06-07T11:49:30Z
Indexed on
2010/06/07
12:52 UTC
Read the original article
Hit count: 304
Hi,
In a WHERE part of query we have
SELECT * FROM SomeTable st
WHERE
NOT EXISTS
(SELECT 1 FROM Tab t1 WHERE t1.A = st.A OR t1.B = st.A)
OR EXISTS
(SELECT 1 FROM Tab t2 WHERE (t2.A = st.A OR t2.B = st.A) AND t2.C IS NULL)
Seems like a good candidate for merging... But I'm staring on that for an hour without any idea.
Would you have some thoughts?
Thanks,
© Stack Overflow or respective owner