I have a table of ID values of users column A has the management users and column B has the users. I want to be able to display a list of user that manage other users, for example.

```

User 1 can manage user 2
User 1 can manage user 3
User 3 can manage user 4
User 5 can manage user 6

```

This produces the following table:

```

--------------------------
|  mgtuserId  |  userId  |
--------------------------
|     1       |     2    |
|     1       |     3    |
|     3       |     4    |
|     5       |     6    |
--------------------------

```

I would like to have a query or stored procedure that returns the list of management users by following them down the hierarchical structure. So that if you are user 1 the following list will be output.

```
 1, 2, 3, 4 
```

Then if you are user 2 then you will only have 2 output.

```
 2 
```

Then if you are user 5 the following list is output and so on.

```
 5, 6 
```

What is the best way to achieve this given that I have each users Id.

Thanks in advance.