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
How can I detect whether a given connection is blocked?
How long can an error message be in raiseerror function?
When installing the datastage7.5x2 edtion iam getting aproblem i.e the cpu count is 2 but the cpu count in installation is one . how can i install in my p.c (system is dual core).
How to customize error conditions.
What is dbms and its application?
You are testing the performance of a query the first time you run the query, the performance is slow. the second time you run the query, the performance is fast. why is this?
Explain about relational database management systems?
Explain about post-relational databases?
Explain the role of indexing in databases?
If a column is an image value type, how you can compare column values? How can you use this column in join clause?
How you can make a parameterized view?
Explain about the hierarchical model of the database?
Explain the process of the user request and data generating?
What is database design and development?
Explain about the database management systems.