答案 0 :(得分:2)
答案 1 :(得分:1)
SELECT distinct TOP(20) e.*, u1.UserName As Sender,
u2.UserName As Receiver, u1.Avatar AS SenderPic
FROM Friends f INNER JOIN Users u
ON(u.Id = f.SenderId OR u.Id = f.ReceiverId) AND State = 'ok'
INNER JOIN Events e
ON(f.SenderId = e.SenderId OR f.SenderId = e.ReceiverId
OR f.ReceiverId = e.SenderId OR f.ReceiverId = e.ReceiverId)
INNER JOIN Users u1
ON (e.SenderId = u1.Id)
INNER JOIN Users u2
ON (e.ReceiverId = u2.Id)
WHERE u.Id = @id;
答案 2 :(得分:0)