-
correlated inner query
how to write a query for finding all the employee-ids under a particular manager:
the table is :
emp
----
empid | ename | mid
----------------------
101 | a | 0 -CEO
102 | b | 101
103 | c | 101
104 | d | 101
105 | e | 102
106 | f | 102
107 | g | 103
108 | h | 104
109 | i | 104
110 | j | 102
111 | k | 105
112 | l | 105
113 | m | 106
114 | n | 112
if u give empid=102, u should get the results-105,106,110,111,112,113,114
if u give empid=101, all the empids should be displayed.
RDBMS used is Postgres (Linux)
also,
when i enter a particular empid, i should get all the empids under him, for eg: if i enter 102, i should get e,f,j,k,l,m,n and if i enter 105, i should get k,l,n
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|