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 few records all are same structures data, I want to store data in multiple targets how
What is the database development process?
Any sample or model question of punjab national bank for deputy manger IT or any sample of PNB.any1 plz do send on
How you can make a parameterized view?
Which data type cannot be used as a parameter in a udf?
What is a database development?
What are the types of database model?
Pgm A calls Pgm B and pgm B uses cursor, when pgm B is called second time, the program is abending saying the cursor is opened? Why?
How to customize error conditions.
There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better?
Explain about the relational database?
Where is dbms used?
Explain about post-relational databases?
To convert IDMS to DB2, how to deal with IDMS occurs and redefined clause?
fact table and dimension table containg one to many relationship or many to one relastionship