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

Where is all the data on the internet stored?

556


Which is faster joins or subqueries?

554


How do I copy a table in sql?

517


What are three advantages to using sql?

553


Can sql function call stored procedure?

558






Determine if oracle date is on a weekend?

556


What is gpt format?

507


Why do we create stored procedures & functions in pl/sql and how are they different?

504


What are all the ddl commands?

628


What are synonyms in sql?

534


what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba

508


how to add a new column to an existing table in mysql? : Sql dba

584


What is optimistic concurrency control? : Transact sql

553


Why use subqueries instead of joins?

608


How do I remove sql plus from windows 10?

568