Hi,
Someone asked me if it were possible to do the following SELECT
statement in MySQL.
I am sure we need a workaround for this.
Can someone please offer any clues or even answers?
 
The statement:
 
SELECT ename, empno, mgrnr,  job 
FROM emp
START WITH job = PRESIDENT""
CONNECT BY PRIOR empno = mgr
 
Outcome:
ename       empno     mgrnr    job
KING           1122                    PRESIDENT
JONES        2233      1122       MANAGER
SCOTT        2345      2233       ANALYST
ADAMS       4567      2233       ANALYST
FORD          6677      1122       MANAGER
SMITH         5432       6677      SALES
BLAJE         5421       6677      SALES
ALLEN         5467       6677      SALES
WARD         9876       1122      MANAGER
MARTIN       5643       9876      CLERK
CLARK        8743       9876      CLERK
MILLER        9832      9876      CLERK
 
Here is what Oracle says about it:
1   Oracle selects the root rows of the hierarchy. These are the rows
that satisfy the condition of the START WITH clause.
2  Oracle selects the child rows of each root row. Each child row must
satisfy the condition of the CONNECT BY clause with respect to one of
the root row.
3 Oracle selects successive generations of child rows. Oracle first
selects the children of the rows returned in step 2, and then the
children of those chilren and so on.
 
Thank you for your time.
Angela Olmeijer
 

Reply via email to