title: How to get the employees and their levels reporting to the manager directly and indirectly without using a CTE in SQL Server?
body: <pre><code>employee_id    manager_id
  1               1
  2               1
  3               1
  4               2
  5               1
  6               3   
  7               2
  8               2
  9               3
  10              2
  </code></pre>
  
  <p>How to get the <code>emanager</code>'s subordinates and their levels without using a CTE? </p>
  
  <p>Because we have to implement the same in MySQL.</p>
  
  <p>Output should be like this</p>
  
  <pre><code>@Managerid = 1
  
  manager_id          employee_id     Level
  1                       2               1 
  1                       3               1
  1                       5               1
  2                       4               2
  2                       7               2
  2                       8               2
  2                       10              2
  3                       9               3
  </code></pre>
  
  <p>level 1 is direct reporting to the manager in question; level 2 and 3... so on are indirect reporting to the manager's reporting employee (also manager for other employees)</p>