title: Decide which table will be in from and which in join based upon condition
body: <p>I have a query which I have written using <a href="http://sqlhints.com/2013/09/07/joining-two-tables-without-any-common-column-between-them-sql-server/" rel="nofollow">This Link</a>.</p>
  
  <p>A <a href="http://www.sqlfiddle.com/#!6/725d3/1/0" rel="nofollow">SQL Fiddle</a> just in case the above link expires.</p>
  
  <p>Sample code:</p>
  
  <pre><code>;WITH MentorTable (CommonId, MentorId, MentorName) AS
  (
      SELECT ROW_NUMBER() OVER(ORDER BY MentorId) AS CommonId,MentorId, MentorName
      FROM Mentor
  )
  ,MenteeTable (CommonId, MenteeId, MenteeName) AS
  (
      SELECT ROW_NUMBER() OVER(ORDER BY MenteeId) AS CommonId,MenteeId, MenteeName
      FROM Mentee
  )
  SELECT MR.MentorId,MR.MentorName,ME.MenteeId,ME.MenteeName
  FROM MentorTable MR
     LEFT OUTER JOIN MenteeTable ME ON MR.CommonId = ME.CommonId
  </code></pre>
  
  <p>I want to get data from five tables and join them without have any common column between them. The above query helps me achieve that. However, in the above query, the Mentortable (which is the from table) will always have more number of records than other tables so all records of other table will be visible with null on remaining rows.</p>
  
  <p>However among my five tables, I dont know which table will have more number of records. I want my query to select from that table so that any rows from the rest of the tables wont be missed out. Also I have to change my join tables accordingly so that all the rest of the tables apart from the "from table" are joined. Any help would be appreciated.</p>