mysql 归类,mySQL 的 2个归类

mySQL 的 2个分类

1、将如下表中的每门成绩都大于80分的人名?

张三

语文

81

张三

数学

75

李四

语文

76

李四

数学

90

王五

语文

81

王五

数学

100

王五

英语

90

select * from tb_stu2;

select distinct stu2_name from tb_stu2 where stu2_name not in

(select distinct stu2_name from tb_stu2 where stu2_score<80);

2、输出老爹对应的大儿子的信息?

create table student(

stu_id int,

stu_age int,

stu_name varchar(30),

stu_f int

);

create table father(

c_id int,

c_master varchar(30)

);

insert into student values(1,28,'王思聪',1);

insert into student values(2,20,'王五',1);

insert into student values(3,24,'李嘉',2);

insert into student values(4,25,'李泽',2);

insert into father values(1,'王健林');

insert into father values(2,'李嘉诚');

#先建立父亲对儿子的一对多的关系,然后选出各自的大儿子显示:

select * from student join father on student.stu_f=father.c_id where (student.stu_age=(select max(stu_age) from student where stu_f=1))

or (student.stu_age=(select max(stu_age) from student where stu_f=2)) ;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值