初学mysql 总结

Posted 程序员JohnDeng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了初学mysql 总结相关的知识,希望对你有一定的参考价值。

今天继续更新初学mysql,接下来下面都是关于必备的查找表的命令。使用表:student
1,查询表全部字段数据:select * from student;
技术分享
2,查询某个字段的数据:select name from student ;
技术分享
3,查询多个字段的数据:select name ,kemu,score from student;
技术分享
4,根据条件查询(where):select * from student where score>80;
技术分享
5,根据多个条件查询(where …and ..):select * from student where kemu=’PE’ and score>80;
技术分享
6,根据首字母为j的名字的学生查询:select * from student where name like ‘j%’;
技术分享
7,根据学生的分数进行排序(升序ASC,降序DESC)查询(order by):select * from student order by score asc;
技术分享
8,根据关键字(in)查询:select * from student where id in (1,2,3);
技术分享
9,查询分数的区间(between and ):select * from student where score between 80 and 90;
技术分享
10,查询分数不重复的数据(distinct):select distinct name ,score from student;
技术分享
11,分组查询(group by): select * from student group by name;
技术分享
12,限制查询结果的数量(limit) :select * from student order by asc limit 5;
技术分享
13,使用常用函数count()查询,好处:若查询字段有null,不会查询出来:
select count(*) from student;
技术分享
14,使用常用函数sum()求总和 :select sum(score) from student;
技术分享
15,使用常用函数avg()求平均值:select avg(score) from student;
技术分享
16,使用常用函数min()求最小值,max()求最大值:
select max(score),min(score) from student;
技术分享

今天暂时更新到这里!



































以上是关于初学mysql 总结的主要内容,如果未能解决你的问题,请参考以下文章

初学者总结的部分实用MySQL函数

初学者总结的部分实用MySQL函数

安装MySQL总结

初学者总结的SELECT数据查询!!!

初学者总结的SELECT数据查询!!!

牛逼!阿里巴巴总结的《MySQL学习笔记》 火了,完整版PDF开放下载!