找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手
1.查找zhao,告知分数
select score from stu where name='zhao';
2.查找wang的年纪和分数
select age, score from stu where name='wang'
3.not in不显示年龄为20,21的所有信息
select * from stu where age not in (20,21);
4.between  19-23以内年龄段所有信息
select* from stu where age between 19 and 23;
5.查找分数为空的所有信息
select * from stu where score is null;
6. 查找分数不为空的所有信息
select * from stu where score is not null;
7. like 模糊匹配开头结尾中间‘’aa%‘’, ‘’%aa‘’,‘’%a%‘’
8.截取某行或者某行到某行limit
查找6-10行  limit 5,5;
查找8-25行  limit 7,18;
查找第7行    limit 6,1;
9.排序
降序  order by desc
升序  order by asc
注意不能where条件后直接接,如果用where需要将条件带上。
10.分组(去重)
根据姓名分组
select * from stu group by name;
select * from

11. create table sheet2 like sheet1;只备份结构,不备份数据
12.备份表的数据
insert into stu1 select * from stu;
insert into stu1(name,age)select name,age from stu;把表中的部分数据备份
13.备份数据库
mysqldump -uroot -p123456 dcs68>dcs68.sql
在交互界面完成
14.还原数据库
mysql -uroot -p123456 xiaoqian<dcs68.sql
还原到xiaoqian这个数据库中

15. mysql中常用的聚合函数(重点)
select count(*)from stu;  统计表中总行数   
select count(*)a from stu 取别名
select count(*)as a from stu 取别名

16. select max score from stu 取最大分数
17. select min score from stu  去最小分数
18. select sum score from stu 求分数最大和
19. select avg score from stu 求平均值

分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 立即注册