gpt4 book ai didi

php - 检查隐私并根据单个查询获取用户

转载 作者:行者123 更新时间:2023-11-29 11:54:13 26 4
gpt4 key购买 nike

我编写了一个查询,其中我正在检查用户是否将其隐私设置为每个人,它将返回该结果,如果用户设置为网络,则当前用户在我的情况下其 5 将检查该用户必须是他的 friend 或 friend friend 的,如果设置为 friend ,那么用户应该是他的 friend :

我尝试了这个查询,但问题是它给出了错误:

#1241 - Operand should contain 1 column(s)

有没有办法以不同的方式编写此查询并获得适当的结果。

SELECT `U`.`UserGUID`, `U`.`FirstName`, `U`.`LastName`
FROM (`Users` U)
LEFT JOIN `UserPrivacy` UP ON `UP`.`UserID`=`U`.`UserID`
WHERE `UP`.`PrivacyLabelKey` = 'group_invite'
AND
IF(UP.Value='everyone',true,'')
OR
(UP.Value='network',U.UserID IN(SELECT F2.FriendID FROM Friends F JOIN Friends F2 ON F.FriendID = F2
.UserID WHERE F.UserID = 5 AND F2.Status='1' AND F.Status='1' GROUP BY F2.FriendID),'')
OR
(UP.Value='friend',U.UserID IN(SELECT FriendID FROM Friends WHERE UserID=5 AND Status=1),'')

AND U.UserID!=5
GROUP BY `U`.`UserID`

最佳答案

试试这个:

SELECT `U`.`UserGUID`, `U`.`FirstName`, `U`.`LastName`
FROM (`Users` U)
LEFT JOIN `UserPrivacy` UP ON `UP`.`UserID`=`U`.`UserID`
WHERE `UP`.`PrivacyLabelKey` = 'group_invite'
AND
IF(UP.Value='everyone',true, IF(UP.Value='network', U.UserID IN(SELECT F2.FriendID FROM Friends F JOIN Friends F2 ON F.FriendID = F2
.UserID WHERE F.UserID = 5 AND F2.Status='1' AND F.Status='1' GROUP BY F2.FriendID), if(UP.Value='everyone',U.UserID IN(SELECT FriendID FROM Friends WHERE UserID=5 AND Status=1),'')))

AND U.UserID!=5
GROUP BY `U`.`UserID`

关于php - 检查隐私并根据单个查询获取用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33476908/

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