gnznroses Posted December 15, 2008 Share Posted December 15, 2008 let's assume I have two tables: users, which includes one column called id, and then a bunch of others) groups, which contains user_id and group_id i need to get a list of users that are in a specific group, and also a list of all of the groups each user is in. i know i could get a list of the users that are in the group, and then run a second query for each user to get the list of groups for each, but is there a way to do this in one query? if i use a Where that includes groups.user_id = users.id then i get duplicates in the user results. if i add Group By to fix that, then i no longer have the list of groups for each user. advice? Link to comment https://forums.phpfreaks.com/topic/136986-combining-this-into-one-query/ Share on other sites More sharing options...
fenway Posted December 15, 2008 Share Posted December 15, 2008 Depending on what you want to do with the group_id's, group_concat() might help. Link to comment https://forums.phpfreaks.com/topic/136986-combining-this-into-one-query/#findComment-716004 Share on other sites More sharing options...
gnznroses Posted December 16, 2008 Author Share Posted December 16, 2008 great, thanks. i'll look into it. i'll leave this open for a day for any other suggestions then i'll mark it solved. Link to comment https://forums.phpfreaks.com/topic/136986-combining-this-into-one-query/#findComment-716364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.