i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee respective manager.. example
empno ename mgr_id
1 john 3
2 paul 3
3 smith 1
4 kevin 1
5 stewart 2

result has to look like this

ename manager
john smith
paul smith
smith john
kevin john
stewart paul


can u plz help me out in this.....

Answer Posted / john bershan

self join will accomplish this task.try below query

select a.ename,b.ename as manager from emp a,emp b
where a.empno = b.mgrid;

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the differences among rownum, rank and dense_rank? : Sql dba

536


Does sql backup shrink transaction log?

551


What do you understand by pl/sql records?

532


What is substitution variable?

581


Why is a trigger used?

525






What is the difference between in and between in sql?

574


Compare sql & pl/sql

606


How to read/write files from pl/sql?

578


What is cross join example?

551


What steps server process has to take to execute an update statement?

506


What are different joins used in sql?

549


what are ddl statements in mysql? : Sql dba

577


what are the 'mysql' command line arguments? : Sql dba

648


What is memory optimized table?

573


What is mdb stand for?

554