title: Should I use a nested select or create a temporary table for this situation in SQL?
body: <pre><code>                  EMPLOYEES
  empno   firstname  lastname    reportsTo    designation
  1002    Murphy     Diane            null    President
  1056    Patterson  Mary             1002    VP Sales
  1076    Firrelli   Jeff             1002    VP Marketing
  1088    Patterson  William          1056    Sales Manager (APAC)
  1102    Bondur     Gerard           1056    Sale Manager (EMEA)
  1143    Bow        Anthony          1056    Sales Manager (NA)
  </code></pre>
  
  <p>This is the table I am dealing with ,here the <strong>column <code>reportsTo</code> refers to <code>empno</code> of the boss</strong>.</p>
  
  <p>I don't know what to <strong>query</strong> to get <strong>the name of the boss of the employee along with his name</strong> as output in MySQL. What I need is something like:</p>
  
  <pre><code>firstname    lastname    assistant_of
  Patterson    Mary        Murphy Diane
  Firrelli     Jeff        Murphy Diane
  Patterson    William     Patterson Mary
  Bondur       Gerard      Patterson Mary
  Bow          Anthony     Patterson Mary
  </code></pre>
  
  <p>What should I do go for a temporary table or can I do it using nested select.</p>
  
  <p>This might question might seem similar to <a href="https://stackoverflow.com/questions/22778295/use-temporary-tables-or-nested-select-in-retrieving-data-from-multiple-table">Use Temporary Tables or Nested Select in retrieving data from multiple table?</a>
  but <strong>"every query is a different story"</strong></p>