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
Where is all the data on the internet stored?
Which is faster joins or subqueries?
How do I copy a table in sql?
What are three advantages to using sql?
Can sql function call stored procedure?
Determine if oracle date is on a weekend?
What is gpt format?
Why do we create stored procedures & functions in pl/sql and how are they different?
What are all the ddl commands?
What are synonyms in sql?
what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba
how to add a new column to an existing table in mysql? : Sql dba
What is optimistic concurrency control? : Transact sql
Why use subqueries instead of joins?
How do I remove sql plus from windows 10?