HOW GET FRIENDS ID IN GROUP [closed]

this should work:

select uid,gid  from group_member where gid in (select gid from group_member where uid=me()) order by gid

It get all the user id and group id from the group where group id is in a group in where you are member.

BUt I suggest you to split it in 2 query: get the ids of the group where you are in and then get, for each group, the ids of the members

select gid from group_member where uid=me()

and then loop through the results

select uid from group_member where gid ={group_id}

for the users data:

Pay attention: more the query is complicated, more will be the time needed

select name from user where uid in(select uid  from group_member where gid in (select gid from group_member where uid=me()))

so i suggest, for each group:

select name from user where uid in(select uid from group_member where gid ={group_id})

here is the user table reference so you can add the fields needed in addition to ‘name’

Leave a Comment