Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Multiple Exists in sub query

755501Mar 31 2010 — edited Dec 20 2012
I am writing a SQL statement that has multiple EXISTS in its sub-select (see below). I want the records to be returned if one or the other EXISTS returns. For performance, is it best to surround the 'EXISTS' with an 'OR'? Is there a better way to do it?

SELECT emp.empid from emp
WHERE
EXISTS(SELECT ''
FROM meets, stu_schedule, stu_school, stu_year, sis_user
WHERE sis_user.user_name = v('APP_USER')
and stu_year.fk_stu_base = stu_base.pk_id
and stu_school.fk_stu_year = stu_year.pk_id
and stu_schedule.fk_stu_school = stu_school.pk_id
and stu_schedule.fk_meets = meets.pk_id
and sis_user.fk_staff = meets.fk_staff)


EXISTS(SELECT ''
FROM staff_assignment, homeroom, stu_school, stu_year, sis_user
WHERE sis_user.user_name = v('APP_USER')
and stu_year.fk_stu_base = stu_base.pk_id
and stu_school.fk_stu_year = stu_year.pk_id
and stu_school.fk_homeroom = homeroom.pk_id
and staff_assignment.fk_homeroom = homeroom.pk_id
and sis_user.fk_staff = staff_assignment.fk_staff)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 17 2013
Added on Mar 31 2010
4 comments
8,309 views