• As far as I can tell, what you are asking for is a simple 5-way join: of course in T-SQL that has to written as 4 nested two-way joins - two bottom level inner joins to get names of parent and child of a given element ID, then join one of those to the element table and that result to the Element table again.

    To make it easier to read and understand it's probably better to put the two bottom level joins in CTEs and use the old notation for the three way join at the outer level - commas and where clause instead of join operators and on clauses - instead of writing the three way join as two two-way joins.

    That gives the following code:

    with EP as (select C.Child_Id, E1.Element_Name as Parent_Name

    from Element E1 inner join Parent_Child C on C.Parent_Id = E1.Element_id),

    EC as (select P.Parent_Id, E2.Element_Name as Child_Name

    from Element E2 inner join Parent_Child P on P.Child_Id = E2.Element_Id)

    select E.Element_Name, EP.Parent_Name, EC.Child_Name

    from Element E, EP, EC

    where EP.Child_Id = E.Element_Id and EC.Parent_Id = E.Element_Id;

    I guessed at table defintions and invented some data and tested it; but as Sean said, you should really provide DML and test data for a query like this, as otherwise you may find someone has guessed wrong.

    Tom