MySQL基础练习

表的一些基本操作

1.导入sql文件

source + 文件位置

2.查询某列的数据

select col1, col2, col3 from table

3.查询所有数据

select * from table

4.查询Score表中成绩在60到80之间的所有记录

select Degree from Score where Degree >= 60 and Degree <=80;

5.查询Score表中成绩为68,86的记录

select Degree from Score where Degree = 68 or Degree =86;

6.查询Student表中“9001”班或性别为“女”的同学记录

select * from Student where Class = '9001' or Ssex = '女';

7.排序查询

7.1 降序关键字desc,以Class降序查询Student表的所有记录

select * from Student order by Class desc;

7.2 升序:order by + colname,以Cno升序、Degree降序查询Score表的所有记录

select * from Student order by Cno, Degree desc;

8.查询student表中“9002”班的学生人数

select count(Class) as '9002' from Student;

9.查询Score表中的最高分和最低分

select max(Degree), min(Degree) from Score;

10.查询Score表每门课的平均成绩

select Sno, avg(Degree) from Score  group by Sno;

11.查询Score表中至少有3名学生选修的,并且课程号以02结尾的课程的平均分数

select Cno, avg(Degree) from Score group by Cno

having Cno like '%02' and count(*) > 3;

上一篇:C# GDAL基础使用之矢量处理4 信息输出打印(GetCRSInfo)


下一篇:一种同构图算法——标准化邻接矩阵算法实现