gpt4 book ai didi

sql - 帮助了解共同 friend 的fql查询

转载 作者:行者123 更新时间:2023-12-02 06:07:54 26 4
gpt4 key购买 nike

需要在不使用JS的情况下获得共同 friend 的姓名和照片。

在下面找到了共同 friend 的FQL查询:
"SELECT uid1 FROM friend WHERE uid2=[targetID] AND uid1 IN (SELECT uid2 FROM friend WHERE uid1=[sourceID])"
有没有一种方法可以让我获得此人的姓名和照片,而不是只返回uid1

编辑
-----------认为我找到了。
"SELECT first_name, last_name, pic_small FROM user WHERE uid IN(SELECT uid1 FROM friend WHERE uid2=['targetID'] AND uid1 IN (SELECT uid2 FROM friend WHERE uid1=['sourceID']))
"

最佳答案

SELECT uid, first_name, last_name, pic_small
FROM user
WHERE uid IN (
SELECT uid2
FROM friend
WHERE uid1 = ['sourceID']
)
AND uid IN (
SELECT uid2
FROM friend
WHERE uid1 = ['targetID']
)

这将找到与源用户(B)和目标用户(C)都为好友的任何用户(A)。不一定相反。 A与B和C成为 friend 。

如果 friend 表确实是镜像的(即,对于每行(x,y),也有行(y,x)),则此区别将无关紧要。

关于sql - 帮助了解共同 friend 的fql查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6867451/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com