我不知道如何解释这个,但我会努力的。我有代码将朋友请求发送给我正在开发的网站的另一个用户。并且有两个电子邮件字段,即req_email(用于请求者)和resp_email(用于响应者)。我目前的代码单独显示发件人字段的朋友。但有时发送者也可以成为响应者,因为其他人可能会向他发送请求。
SELECT CASE WHEN status = 'Yes' THEN 'Friends'
ELSE CASE WHEN status = 'No' THEN 'Request Sent'
ELSE CASE WHEN status IS NULL THEN 'Send Request' END
END
END AS Answer,
*
FROM dbo.profile p
LEFT JOIN friends f On p.email = f.[resp_email] AND f.[req_email] = MMColParam
WHERE fname LIKE %varsearch%
AND email NOT LIKE MMColParam2
ORDER BY fname ASC
现在我的问题是如何将sender_email和响应者电子邮件合二为一,以便在一个实例中返回结果
答案 0 :(得分:0)
您的查询错误。请检查以下查询:
SELECT CASE WHEN status = 'Yes' THEN 'Friends'
WHEN status = 'No' THEN 'Request Sent'
WHEN status IS NULL THEN 'Send Request'
END AS Answer,
*
FROM dbo.profile p
LEFT JOIN friends f On p.email = f.[resp_email] AND f.[req_email] = MMColParam
WHERE fname LIKE '%varsearch%'
AND email NOT LIKE 'MMColParam2'
ORDER BY fname ASC