您的位置:首页 > 数据库 > MySQL

mysql 查询一张表没有存在在另一张表的数据

2016-03-11 14:05 701 查看
student表

id
name

1 张三

2 李四

3 王五

4 赵四

result表

id score

1 80

2 60

查询没有考试成绩的学生

方法1:

select *
from student
where id
not
in
(select id
from result)

方法2:

select
* from
student where
not exists
(select 1
from result
where result.id= student.id
)

方法3:

select
student.* from
student left join
result on
(studeng.id = result.id) where
result.id is null
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: