what is use of self join and which cases you will use this join



what is use of self join and which cases you will use this join..

Answer / vidhya

A physical file can be joined to itself to read records that are formed by combining two or more records from the PF itself.
For example
You use a self join when a table references data in itself.

E.g., an Employee table may have a SupervisorID column that points to the employee that is the boss of the current employee.

To query the data and get information for both people in one row, you could self join like this:

select e1.EmployeeID,
e1.FirstName,
e1.LastName,
e1.SupervisorID,
e2.FirstName as SupervisorFirstName,
e2.LastName as SupervisorLastName
from Employee e1
left outer join Employee e2 on e1.SupervisorID = e2.EmployeeID

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More DB400 Interview Questions

How to insert more than one record to a pf at a time?(Bulk insert to a pf)

9 Answers  


what is the difference between adding keys & constraints into a phisical file

4 Answers   HSBC,


what is error handling concepts in cl

3 Answers   Active Brains,


Define interactive jobs and batch jobs

6 Answers  


Which keyword is used both in subfile and subfile control record format of a DSPF?

8 Answers  






How to update physical file using logical file with example?

0 Answers  


What is the interactive job?

0 Answers  


Can we concatenate fields in physical file? If yes how can we do?

0 Answers  


What is the primary file?

0 Answers  


In how many ways we can create a logical file?`

5 Answers  


When we use any keyword like FIFO,LIFO, at file level but whenever we check by runqry we couldn't find answer in FIFO,LIFO,FCFO etc so how we check the answer.

2 Answers  


what is general and type of general

1 Answers   Active Brains,


Categories