我使用此代码来获取我所属的朋友。但是没有工作......!
select uid2 from friend where uid1 IN (SELECT uid FROM group_member WHERE gid = '111111111')
答案 0 :(得分:2)
这应该有效:
select uid,gid from group_member where gid in (select gid from group_member where uid=me()) order by gid
它从组成员所在的组中获取所有用户ID和组ID。
BUt我建议你将它拆分为2个查询:获取你所在组的ID,然后为每个组获取成员的ID
select gid from group_member where uid=me()
然后循环结果
从group_member中选择uid,其中gid = {group_id}
用户数据:
注意:查询越复杂,需要的时间就越多
select name from user where uid in(select uid from group_member where gid in (select gid from group_member where uid=me()))
所以我建议,每个小组:
从uid所在的用户中选择名称(从group_member中选择uid,其中gid = {group_id})
here是用户表引用,因此除了'name'