一个简单的MYSQL题

codinghom 2014-09-21 01:26:13
如何求物理没考过100分的学生?

表和测试数据
学生表
ID NAME
1 A
2 B

成绩表:
SUTID SUB SCORE unit
1 物理 100 1
1 物理 99 2
2 物理 98 1
2 物理 99 2

...全文
187 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
codinghom 2014-09-25
  • 打赏
  • 举报
回复
引用 10 楼 gaofei8704 的回复:
[quote=引用 9 楼 bushinagewo 的回复:] [quote=引用 6 楼 gaofei8704 的回复:] 哎……不忍直视的答案,少年,给你绝对正确的:

select t1.* 
from 学生表 t1
left join (select distinct SUTID from 成绩表 where SCORE=100) t2
on t1.ID=t2.SUBID
where t2.SUBID is null
这个是求考100的吧~[/quote] ……看清楚,我是将所有烤过100分的人过滤掉的 left join!!不要误导别人啊[/quote] sorry,没看全了0 0
沟沟里的农民 2014-09-24
  • 打赏
  • 举报
回复
引用 7 楼 eeight 的回复:
[quote=引用 3 楼 orangeholic 的回复:]
select * from 学生表 inner join 成绩表 on  学生表.id=成绩表.sutid  where sub =‘物理’ and score<100 ;
这个。[/quote]
引用 8 楼 bushinagewo 的回复:
[quote=引用 2 楼 WolfOfSiberian 的回复:] select * from 学生表,成绩表 where score<100 and sub =‘物理’ and 学生表.id=成绩表.sutid;
引用 3 楼 orangeholic 的回复:
select * from 学生表 inner join 成绩表 on  学生表.id=成绩表.sutid  where sub =‘物理’ and score<100 ;
引用 7 楼 eeight 的回复:
[quote=引用 3 楼 orangeholic 的回复:]
select * from 学生表 inner join 成绩表 on  学生表.id=成绩表.sutid  where sub =‘物理’ and score<100 ;
这个。[/quote] 没考过100 != 考了没100的吧[/quote] 没考过的意思,不是考试的分数少于100的意思吗?不知道楼主的理解应该是怎么样的?
gaofei8704 2014-09-24
  • 打赏
  • 举报
回复
引用 9 楼 bushinagewo 的回复:
[quote=引用 6 楼 gaofei8704 的回复:] 哎……不忍直视的答案,少年,给你绝对正确的:

select t1.* 
from 学生表 t1
left join (select distinct SUTID from 成绩表 where SCORE=100) t2
on t1.ID=t2.SUBID
where t2.SUBID is null
这个是求考100的吧~[/quote] ……看清楚,我是将所有烤过100分的人过滤掉的 left join!!不要误导别人啊
codinghom 2014-09-24
  • 打赏
  • 举报
回复
引用 6 楼 gaofei8704 的回复:
哎……不忍直视的答案,少年,给你绝对正确的:

select t1.* 
from 学生表 t1
left join (select distinct SUTID from 成绩表 where SCORE=100) t2
on t1.ID=t2.SUBID
where t2.SUBID is null
这个是求考100的吧~
codinghom 2014-09-24
  • 打赏
  • 举报
回复
引用 2 楼 WolfOfSiberian 的回复:
select * from 学生表,成绩表 where score<100 and sub =‘物理’ and 学生表.id=成绩表.sutid;
引用 3 楼 orangeholic 的回复:
select * from 学生表 inner join 成绩表 on  学生表.id=成绩表.sutid  where sub =‘物理’ and score<100 ;
引用 7 楼 eeight 的回复:
[quote=引用 3 楼 orangeholic 的回复:]
select * from 学生表 inner join 成绩表 on  学生表.id=成绩表.sutid  where sub =‘物理’ and score<100 ;
这个。[/quote] 没考过100 != 考了没100的吧
eeight 2014-09-24
  • 打赏
  • 举报
回复
引用 3 楼 orangeholic 的回复:
select * from 学生表 inner join 成绩表 on  学生表.id=成绩表.sutid  where sub =‘物理’ and score<100 ;
这个。
gaofei8704 2014-09-24
  • 打赏
  • 举报
回复
哎……不忍直视的答案,少年,给你绝对正确的:

select t1.* 
from 学生表 t1
left join (select distinct SUTID from 成绩表 where SCORE=100) t2
on t1.ID=t2.SUBID
where t2.SUBID is null
jielovehuan 2014-09-23
  • 打赏
  • 举报
回复
楼上正解。。。。。。
q598584210 2014-09-23
  • 打赏
  • 举报
回复
select * from 学生表 inner join 成绩表 on  学生表.id=成绩表.sutid  where sub =‘物理’ and score<100 ;
侑子的小伙伴 2014-09-22
  • 打赏
  • 举报
回复
select * from 学生表 inner join 成绩表 on  学生表.id=成绩表.sutid  where sub =‘物理’ and score<100 ;
沟沟里的农民 2014-09-21
  • 打赏
  • 举报
回复
select * from 学生表,成绩表
where score<100 and sub =‘物理’ and 学生表.id=成绩表.sutid;
ACMAIN_CHM 2014-09-21
  • 打赏
  • 举报
回复
select * from 学生表 where ID not in (select SUTID from 成绩表 where SCORE=100 and SUB='物理')

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧