What is a self join? Explain it with an example?

Answer Posted / madhavi

Joining the table to itself is self join.
Example:

To find the manager name for each employee in the employee
table:
select e1.empno employee_id,e1.ename employee_name,e2.ename
manager_name,e2.empno employee_num from emp e1,emp e2 where
e1.empno=e2.mgr;

Is This Answer Correct ?    27 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you log an error to the server event log from a stored procedure?

563


Explain the cube operator?

607


How to generate OIDS

1666


You have a table with three columns: amount1, amount2, and amount3 in a single row only one of these three columns will have a value and the other two will be null. Write a sql query to retrieve the values from these columns?

551


Write short notes on manual refreshes.

2295






To convert IDMS to DB2, how to deal with IDMS occurs and redefined clause?

3441


I have a few records all are same structures data, I want to store data in multiple targets how

2147


Who are naive users?

611


Explain about post-relational databases?

585


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?

2014


How to replace not in with not exist?

1470


Explain about normal forms?

604


What are the types of database model?

550


What are the constraints on severity level in raiseerror?

588


How is data stored in dbms?

528