SELECT DISTINCT
rev1.name,
rev2.name
FROM reviewer rev1,
reviewer rev2,
(SELECT r1.rid AS r1id,
r2.rid AS r2id
FROM rating r1,
rating r2
WHERE r1.mID = r2.mID
AND r1.rid < r2.rID
) AS raters
WHERE rev1.rid = raters.r1id
AND rev2.rid = raters.r2id
ORDER BY rev1.name DESC;
此 sqlite 代码返回以下对:
Brittany Harris Chris Jackson
Chris Jackson Ashley White
Daniel Lewis Elizabeth Thomas
Elizabeth Thomas James Cameron
Sarah Martinez Mike Anderson
对中的名称是正确的,但其中一些应该显示相反,也就是说,结果应该是:
Ashley White Chris Jackson
Brittany Harris Chris Jackson
Daniel Lewis Elizabeth Thomas
Elizabeth Thomas James Cameron
Mike Anderson Sarah Martinez
如果有人能指出我做错了什么,我将不胜感激。提前感谢您提供的任何帮助。