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,
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

I had created one physical file tell me command to enter data in to?

0 Answers  

Can anybody tell why Journalling is compulsary before Commitment Control?

2 Answers  

How to index LF by relative record no (RRN)

0 Answers  

If we use the file level keywords like LIFO, FIFO, FCFO in a file, can we see the impact of it by doing the run query of the file? if not how can we see the impact of these keywords.

2 Answers  

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

4 Answers   HSBC,


5 Answers   Accenture,

Why we create the Physical File Member?

5 Answers  

How can we know that a trigger has been added on a PF? and what is the purpose of adding a trigger?

3 Answers  

How to update physical file using logical file with example?

0 Answers  

In a CL Program after executing a SQL SP how to receive a Output value from the SP. Just to make it clear I am sending 2 input and 1 output parameter to the SQL Stored Procedure. Now while receiving it output parm it is failing.

0 Answers   Nous,

I have a PF with out any data but the dependent LF is having data?

1 Answers   HCL,

pls anyone explain about compile time array,pre run time array run time array

4 Answers