Nigel Thomas
Nigel Thomas

Reputation: 1929

Query all the employees under a single employee

I have an Employees table. I am using Oracle database.

 Employees Table
 - Employee_id
 - first_name
 - last_name
 - manager_id
 - email_id

How can I query all the employees under another employee ?

Thanks.

Upvotes: 1

Views: 145

Answers (1)

MatBailie
MatBailie

Reputation: 86798

Oracle has a CONNECT BY syntax...

    SELECT *
      FROM employees
START WITH employee_id = 123
CONNECT BY PRIOR employee_id = manager_id

Upvotes: 2

Related Questions