mysql使用not exists查询满足条件的所有人

表结构
clipboard.png

查询所有分数为80分以上的人:
SQL语句

SELECT DISTINCT
    t1.student_id
FROM
    scores t1
WHERE
    NOT EXISTS (
        SELECT
            *
        FROM
            scores t2
        WHERE
            t1.student_id = t2.student_id
        AND t2.score < 80
    );

问题:
为什么not exists 里面的 and t2.score < 80 不能是t1.score < 80 呢?

阅读 2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题