What is a self join? Explain it with an example?
Answer Posted / anuj barthwal
A self join applies on one table only
Example:
emp_id emp_name emp_manager_id
1 Anuj NULL
2 Sunny 1
3 Suraj 1
4 Narban 2
if we want to get the name of the managers
select e1.emp_name 'manager',e2.emp_name 'employee'
from employees e1 join employees e2
on e1.emp_id=e2.emp_manager_id
manager employee
Anuj Sunny
Anuj Suraj
Sunny Narban
Self join means joining the single table to itself
| Is This Answer Correct ? | 5 Yes | 2 No |
Post New Answer View All Answers
I HAVE A PI ON COL A THE NEXT DAY I WANT CHANGE THE PI ON COL B? PLS SEND ME THE ANS
What are the three basic rules which are to be followed for the relational model of the database?
Explain about network model?
In which table collections errors are stored.
What are the three types of database design?
Who are end users in dbms?
What you can do to remove data from the cache and query plans from memory for testing the performance of a query repeatedly?
What is a database development?
What is the physical representation for a many-to-many relationship?
How can I detect whether a given connection is blocked?
What is dbms explain in brief?
Explain about normal forms?
What is an application role and explain a scenario when you would use one?
Explain the rollup operator?
Which four data types cannot be used as a return type from a user-defined function?