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 is java sql connection?

692


What are the advantages of pl sql?

834


What is right join sql?

711


What is the difference between the repeatable read and serializable isolation levels? : Transact sql

743


What is example of database?

699






How do you declare a user-defined exception?

718


What are the different sql commands?

722


What does the base_object_type column shows in the user.triggers data dictionary view?

759


explain mysql aggregate functions. : Sql dba

724


what are the features and advantages of object-oriented programming? : Sql dba

727


Can we perform dml in function?

796


How do you exit in sql?

815


What is pivot table in sql?

735


explain advantages of innodb over myisam. : Sql dba

829


what is single byte over head in oracle..?

2090