Hi all,
i have a table as follows
empid empname mgrid deptid
1 a 3 4
2 b 1 5
3 c 2 3
4 d 3 6
5 e 4 7

i want the output as
empname mgrname
a c
b a
c b
d c
e d

Answer Posted / suresh babu

select t1.empname,t2.empname from emp t1,emp t2 where
t1.mgrid = t2.empid;

This query is self join,Which is display your requirement.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to start oracle sql developer?

566


How does sql*loader handles newline characters in a record? : aql loader

591


What is mutating table error?

673


What is primary key secondary key alternate key candidate key?

556


how would you get the current date in mysql? : Sql dba

555






When is the explicit cursor used ?

599


How many types of relationship are there?

555


What is data control language (dcl)?

611


What is the difference between view and stored procedure?

499


Why self join is used in sql?

508


Why stored procedure is better than query?

516


What is auto increment feature in sql?

629


What is the difference between rename and alias?

719


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

516


What is parameter substitution in sql?

536