开发者

PHP Mysql get users by groupid

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 开发者_C百科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.


Use a JOIN statement to link the two tables together.

SELECT groups.groupid, users.name
FROM groups
JOIN users ON users.id = groups.leaderid
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜