Currently in one of our products we have a query with logic as explained below:
create table temp (emp_id varchar2(3), manager_id varchar2(3) )
Data :
E10 E20
E20 E50
E30 E50
E50 E90
Query:
select *
from Temp
Start with EMP_ID = 'E90'
Connect by Prior EMP_ID = MANAGER_ID and EMP_ID != MANAGER_ID
order by EMP_ID
I understand the concept of the query [& connect by] which is that we need to fetch all the children records of the employee specified including the current employee record. I have doubts about the need of adding EMP_ID != MANAGER_ID in the end.
The question is why was it added & in what situation will it be useful [if any].