Please help me to write this query. I faced this question in an interview.
tblEmployee
| Emp_id | Emp_Name | Emp_Gender |
| 1 | John | Male |
| 2 | Dean | Male |
| 3 | Mary | Female |
tblRelatives
| Emp_id | Relatives_Id |
| 1 | 2 |
| 1 | 3 |
Write a query to get the output given below.
| Emp_id | Emp_Name | Father | Morther |
| 1 | John | Dean | Mary |

Ananth GRank #1,176 · 1.5K reputationPosted Oct 31, 2016, 12:40 AM EDT
Satish Patel81 reputationPosted Nov 1, 2016, 9:01 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Oct 29, 2016, 12:07 PM EDT
Midhun TpRank #388 · 6.5K reputationPosted Oct 30, 2016, 5:26 AM EDT
You will get the desired output with below query -
But I'm not sure about what happens with more employees and more relations :)