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
What are the key features of dbms?
How can you fix a poorly performing query?
What are the types of database model?
What is a database development?
What are the constraints on severity level in raiseerror?
On friday, you issued several insert statements using query analyzer. You then verified the data had been correctly entered with a select statement on monday, your users report that the data is not there what happened?
How to use online Backups?
What you can do to remove data from the cache and query plans from memory for testing the performance of a query repeatedly?
Explain about xml databases?
Can an extended stored procedure be called from inside a user-defined function?
What is the physical representation for a many-to-many relationship?
Explain the cube operator?
Write the fastest query to find out how many rows exist in a table?
Explain about network model?
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).