If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Recursive MySQL

Well on a side note this is my first post, but seems like an excellent community. Now onto business...<br>
<br>
I've looked around at several approaches, but basically I have a table of employees, and one column stores a supervisor ID. For example:<br><br><table class="wysiwyg_dashes" width=""><tbody><tr class="wysiwyg_dashes_tr"><td class="wysiwyg_dashes_td">ID</td><td class="wysiwyg_dashes_td">LastName</td><td class="wysiwyg_dashes_td">FirstName</td><td class="wysiwyg_dashes_td">Department</td><td class="wysiwyg_dashes_td">Manager</td><td class="wysiwyg_dashes_td">Title</td></tr><tr class="wysiwyg_dashes_tr"><td class="wysiwyg_dashes_td">1</td><td class="wysiwyg_dashes_td">Smith</td><td class="wysiwyg_dashes_td">John</td><td class="wysiwyg_dashes_td">Administration</td><td class="wysiwyg_dashes_td"><br></td><td class="wysiwyg_dashes_td">President</td></tr><tr class="wysiwyg_dashes_tr"><td class="wysiwyg_dashes_td">2</td><td class="wysiwyg_dashes_td">Johnson</td><td class="wysiwyg_dashes_td">Sally</td><td class="wysiwyg_dashes_td">Administration</td><td class="wysiwyg_dashes_td">1</td><td class="wysiwyg_dashes_td">Secretary</td></tr><tr class="wysiwyg_dashes_tr"><td class="wysiwyg_dashes_td">3</td><td class="wysiwyg_dashes_td">Waters</td><td class="wysiwyg_dashes_td">Andrew</td><td class="wysiwyg_dashes_td">HR</td><td class="wysiwyg_dashes_td">1</td><td class="wysiwyg_dashes_td">HR Manager</td></tr><tr class="wysiwyg_dashes_tr"><td class="wysiwyg_dashes_td">4</td><td class="wysiwyg_dashes_td">McNally</td><td class="wysiwyg_dashes_td">Kevin</td><td class="wysiwyg_dashes_td">Sales</td><td class="wysiwyg_dashes_td">1</td><td class="wysiwyg_dashes_td">VP, Sales</td></tr><tr class="wysiwyg_dashes_tr"><td class="wysiwyg_dashes_td">5</td><td class="wysiwyg_dashes_td">Watson</td><td class="wysiwyg_dashes_td">Adam</td><td class="wysiwyg_dashes_td">Sales</td><td class="wysiwyg_dashes_td">4</td><td class="wysiwyg_dashes_td">Sales Associate</td></tr><tr class="wysiwyg_dashes_tr"><td class="wysiwyg_dashes_td">5</td><td class="wysiwyg_dashes_td">Wilkinson</td><td class="wysiwyg_dashes_td">Mary</td><td class="wysiwyg_dashes_td">Sales</td><td class="wysiwyg_dashes_td">4</td><td class="wysiwyg_dashes_td">Sales associate</td></tr></tbody></table><br>I am working on an application for mangers to login and view employee information. I could easily get it working for a manger to view employees directly beneath, but I would like managers to view ALL employees under him. For example, John Smith should see those records of people who directly report to him, but also those that report to people who directly report to him. &nbsp;In this example, John Smith should have access to ALL records. &nbsp;I am using PHP and MySQL, and just can not grasp the SQL queries behind this one. I can imagine using recursion somehow, but i'm&nbsp;fairly&nbsp;new to this.<br><br>Thank you!