title: How to join the subquery result(having nested joins ) with another table?
body: <p>I am implementing nested join statement using sub-queries. I am able to get the result for 3 tables but unable to join it further for four or n tables .</p>
  
  <pre><code>SELECT X.personCityId
       , X.name
       , X.age
       , X.cityId
       , X.state
       , Y.age 
       , Y.name 
    FROM (SELECT Person.cityId AS personCityId
               , Person.name
               , Person.age
               , CityDetails.cityId AS cityId
               , CityDetails.state 
            FROM Person 
                 LEFT JOIN CityDetails 
                        ON Person.cityid = CityDetails.cityid ) AS X 
          LEFT JOIN (SELECT name , age, lastname FROM PersonalDetails) AS Y 
                 ON X.age=Y.age
  </code></pre>
  
  <p>Let say if i have to join result of above query with  4th table by left join on <code>age</code> column  </p>
  
  <p><code>LEFT JOIN (SELECT age,height, weight from PersonMedicalRecords ) as D ON Z.age = a.age</code></p>
  
  <p>I want to know how this can be done through sub-queries only.</p>