赞
踩
检索出年龄大于23岁的男同学的基本信息,查询结果按学号升序排列。
提示:请使用SELECT语句作答,计算年龄用timestampdiff函数。
定义表结构的SQL语句如下:
CREATE TABLE student (
sno varchar(6) NOT NULL ,
sname varchar(10) ,
sex char(2) ,
nation char(2) ,
pnum char(18) ,
birth date ,
phone char(11) ,
dept varchar(20) ,
PRIMARY KEY (sno)
) ;
上述表结构对应的表样例:
student表:

输出样例:

-
- select *
- from student
- where timestampdiff(YEAR,birth,"2020-12-01")>=23
- and sex='男'
- order by sno
-
-
发这一题不是它难,主要是这题没给时间, 所以我就发上来了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。