Re-querying table within same query?

Rando

New member
Local time
Today, 12:07
Joined
Sep 22, 2010
Messages
8
Hello,

I have a situation which I've not encountered before since I'm fairly new to SQL. I have a table that contains every single user within a building. Each user has a supervisor ID # that indicates who they report to. Since I have their ID # I would like to re-query the same table and get their name. How can I do this?


Table Data:
Code:
ID	Name		SupervisorID
12345	Susie Tester	98751
54321	Iam Testy	
54654	Tom McTest	
46546	Sammy Sample	54654
98751	Mark Debug	
65465 	Super Shopper	12345

Expected Results:
Code:
ID	Name		Supervisor
12345	Susie Tester	Mark Debug
54321	Iam Testy	
54654	Tom McTest
46546	Sammy Sample	Tom McTest
98751	Mark Debug	
65465 	Super Shopper	Susie Tester

I'm not too concerned with users not having a supervisor ID #. Thanks for any help
 
Use a query. Drop the two tables onto the design grid, it may link both tables via ID - right-click and delete it if it does, link the SupervisorID field of table 1 to the ID field of the second table (which is a copy). You may need to change the join to a Left join (where it includes all values from table 1).
 

Users who are viewing this thread

Back
Top Bottom