Reputation: 3462
This is actually a pretty straight forward problem I just can't seem to think about how to do it right now. Alright so I have two tables Users and Groups on my landing page I have a dropdown that displays all of the groups each group has a group leader which is a user. So in my groups table I have the fields id,groupid,leaderid. leaderid connects to users.id I need to loop through the groups and grab/join the leader's information if anyone can help it would be much appreciated.
Upvotes: 0
Views: 190
Reputation: 50318
Use a JOIN
statement to link the two tables together.
SELECT groups.groupid, users.name
FROM groups
JOIN users ON users.id = groups.leaderid
Upvotes: 2