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

how to check server status with 'mysqladmin'? : Sql dba

565


What is nested table in pl sql?

548


what are the advantages of mysql in comparison to oracle? : Sql dba

524


What is optimistic concurrency control? : Transact sql

544


Are stored procedures faster than queries?

520






What is set serveroutput on?

637


How can I tell if sql is running?

583


Which is faster joins or subqueries?

548


What are the two types of periodical indexes?

501


Describe sql comments?

556


What is sqlerrd?

524


What is the source code of a program?

503


how to use in conditions? : Sql dba

508


How consistent is the view of the data between and within multiple sessions, transactions or statements ?

1704


How do I run a pl sql program?

623