I on looking for a sql code (preferably with joins, not with cursors or stored proc or variables).
We have a parent manager-employee relationship in a database table, where the manager erroneously becomes the employee for some of the succeeding verticals/records, Example below:
Reporting Manager Employee
1 2
2 3
3 4
4 1 --<< Circular Reference
(The last record is wrong, and creates a circular reference with the first record, as 1 cannot report back to 4)
I am looking forward to find these records who pose this kind of a circular reference, any help is really appreciated.
I have attached a pic of how the data looks like.