Starr Duskk
asked on
Reworking a NOT IN query
Can you advise on how to rework this section? using a JOIN or the best method for tuning? thanks!
AND
(
TrainingCourse.TrainingCourseId IN (Select TrainingCourseId from TrainingCourseUnit WHERE UnitId IN (Select UnitId from EmployeeUnitJobTypeUnitView where EmployeeId = Employee.EmployeeId))
OR
TrainingCourse.TrainingCourseId NOT IN (Select TrainingCourseId from TrainingCourseUnit)
)
To best analyze/correct performance, would need to see the definition of "EmployeeUnitJobTypeUnitVi ew" and the current query plan for this code snippet.
ASKER
Can you just give me a generalization on if I'm using a
where NOT IN (select....
you suggest something better....
like instead of using a
where IN (select
I'd use a join clause.
thanks.
where NOT IN (select....
you suggest something better....
like instead of using a
where IN (select
I'd use a join clause.
thanks.
Provide the complete query.
ASKER
select * from table where otherfieldID NOT IN (select otherfieldID from OtherTable)
I don't think you provided the complete query. There is Employee in the WHERE condition. Without knowing the full query, its tough to reconstruct.
ASKER
Okay, PLEASE FORGET my first example.
All I want to know is another option for a NOT IN.
Can anyone please give me some examples based on this simple little query?
select * from table where otherfieldID NOT IN (select otherfieldID from OtherTable)
thanks.
All I want to know is another option for a NOT IN.
Can anyone please give me some examples based on this simple little query?
select * from table where otherfieldID NOT IN (select otherfieldID from OtherTable)
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent! Thanks!