1. mysql在dos中查看中文乱码问题解决

  2. 字段修改
    alter table <table名> modify column <column名> xxxx.
    alter table student modify column age int unsigned not null.

  3. 单表查询

1、查询学生"百里守约"的基本信息
select * from student where name='百里守约'
2、查询学生"百里守约"或”百里玄策”的基本信息
select * from student where name='百里守约' or name='百里玄策'
3、查询姓"张"学生的姓名,年龄,班级
select name,age,class from student where name like '张%'
4、查询姓名中含有"约"字的学生的基本信息
select * from student where name like '%约%'
5、查询姓名长度为三个字,姓“孙”的学生的学号,姓名,年龄,班级,身份证号
select studentNo,name,age,class,card from student where name like '孙__'
6、查询姓"百"或者姓”孙”的学生的基本信息
select * from student where name like '百%' or name like '孙%'
7、查询姓"百"并且家乡是"山西"的学生信息
select * from student where name like '百%' and hometown='山西'
8、查询家乡是"北京"、”新疆”、”山东”或者"上海"的学生的信息
select * from student where hometown in('北京','新疆','山东','上海')
9、查询姓"孙",但是家乡不是"河北"的学生信息
select * from student where name like '孙%' and hometown!='河北'
10、查询家乡不是"北京"、"新疆"、"山东"、"上海"的学生的信息
select * from student where hometown not in('北京','新疆','山东','上海')
11、查询全部学生信息,并按照“性别”排序
select * from student order by sex
12、查询现有学生都来自于哪些不同的省份
select hometown from student group by hometown
13、查询所有男生,并按年龄升序排序
select * from student where sex='男' order by age
14、统计共有多少个学生
select count(*) from student
15、统计年龄大于20岁的学生有多少个
select count(*) from student where age>20
16、统计男生的平均年龄
select avg(age) from student where sex='男'
17、查询1班学生中的最大年龄是多少
select max(age) from student where class='1班'
18、统计2班男女生各有多少人
select class, sum(sex='男') as '男', sum(sex='女') as '女' from student group by class;
19、统计每个班级中每种性别的学生人数,并按照班级升序排序
select class,sex,count(*) from student group by class,sex order by class
20、查询年龄最小的学生的全部信息
select * from student order by age limit 1
select * from student where age=(select min(age) from student);
1、查询学号是'007'的学生的身份证号
select * from student where studentNo='007'
2、查询'1班'以外的学生信息
select * from student where class!='1班'
3、查询年龄大于20的学生的姓名和性别
select studentNo,sex from student where age>20
1、查询河南或河北的学生
select * from students where hometown='河南' or hometown='河北'
2、查询'1班'的'上海'的学生
select * from student where class='1班' and hometown='上海'
3、查询非20岁的学生
select * from student where not age=20
1、查询姓名为两个字的学生
select * from student where name like '__'
2、查询姓百且年龄大于20的学生
select * from students where name like '百%' and age>20
3、查询学号以1结尾的学生
select * from student where studentNo like '%1'
1、查询年龄在18或19或22的女生
select * from student where age between 18 and 22
2、查询年龄在20到25以外的学生
select * from student where not age between 20 and 25
1、查询所有学生信息,按班级从小到大排序,班级相同时,再按学号再按学号从小到大排序
select * from student order by class,studentNo
1、查询所有学生的最大年龄、最小年龄、平均年龄
select max(age),min(age),avg(age) from students
2、一班共有多少个学生
select count(*) from student where class='1班'
3、查询3班年龄小于18岁的同学有几个
select count(*) from student where age<18
查询各个班级学生的平均年龄、最大年龄、最小年龄
select class,max(age),min(age),avg(age) from student group by class
查询1班除外其他班级学生的平均年龄、最大年龄、最小年龄
select class,max(age),min(age),avg(age) from student group by class having class!='1班'
查询第4到第6行学生信息
select * from student limit 3,3
每页显示5条数据,显示每一页的数据
select * from student limit 0,5

Mysql总结-1 单表查询相关推荐

  1. mysql数据库之单表查询

    单标查询 单表查询语句 关键字执行的优先级 简单查询 where约束 group by 聚合函数 HAVING过滤 order by 查询排序 LIMIT限制查询的记录数 使用正则表达式查询 单表查询 ...

  2. Mysql梳理(单表查询)

    DQL 1.基本查询. 自关联:同一表的不同列之间关联: #查询某列或多列或所有列: select enamel from emp: select enamel,sal,comm from emp: ...

  3. Mysql数据库的单表查询

    我们在使用Mysql数据库存储数据时,对数据的查询方法是至关重要的,此博客主要介绍Mysql数据库的查询数据方法. 单表查询 单表查询就是我们仅对一个表进行查询,我们可以首先创建一个名为table的表 ...

  4. mysql怎么进行单表查询_MySQL之单表查询

    一.单表查询的语法 SELECT 字段1,字段2... FROM 表名 WHERE 条件 GROUP BY field HAVING 筛选 ORDER BY field LIMIT 限制条数 二.关键 ...

  5. mysql 连表查询 好处,MySQL 多次单表查询和多表联合查询的优缺点分析-Fun言

    前言 阿里巴巴的代码规范中有一条就是不建议执行三张表以上的多表联合查询,因为对数据量不大的应用来说, 多表联合查询开发高效, 但是多表联合查询在表数据量大, 并且没有索引的时候, 如果进行笛卡儿积, ...

  6. 【一周入门MySQL—2】单表查询

    单表查询 数据查询语言DQL 单表查询的基本语法: 全表查询:select * from 表名; 查询指定列:select 字段1[,字段2] from 表名; 别名的设置:select 字段 [as ...

  7. MySQL练习(单表查询和多表查询)

    单表查询 一.创建素材 DROP TABLE IF EXISTS `course`; CREATE TABLE `course` (`cs_id` int(11) NOT NULL COMMENT ' ...

  8. cmd操作MySQL 范式、单表查询(日记 day 3)

    今天记录一下设计范式,还有一些简单的查询操作 先来了解一下范式: 范式是分等级的,越高级的范式限制越多,而且,每条范式总是满足它前面的那些低等级范式 第一范式: 每一列都是不可分割的原子数据项 就比如 ...

  9. mysql 数据操作 单表查询 where约束 between and or

    WHERE约束 where字句中可以使用: 比较运算符:>< >=  <=  != between 80 and 100 值在80到100之间   >=80  <= ...

最新文章

  1. 第二代NumPy?阿里开源超大规模矩阵计算框架Mars
  2. 单片机里XPL是什么_单片机可以替代PLC么?
  3. 【NOIP2013模拟联考5】休息(rest)
  4. mysql cmd链接不上数据库情况汇总
  5. 一个最简单的WebSocket hello world demo
  6. 奇奇seo优化软件_西藏seo关键词优化软件
  7. lock和synchronized的同步区别与选择
  8. nagios客户端nrped服务方式启动脚本
  9. OSChina 周日乱弹 —— 在宅的路上越走越远。。。
  10. STP的根端口与指定端口
  11. PL/SQL Developer图形化窗口创建数据库(表空间和用户)以及相关查询sql
  12. 使用EasyPoi导出word并转换为pdf
  13. mac开发者身份_如何以开发者的身份环游世界
  14. Toony Colors Pro 2项目分析——身体其他部位shader
  15. 渗透测试-Python安全工具编程基础
  16. WIN10下用anaconda安装tensorflow-gpu1.8.0并用pycharm作编译器(WIN10下anaconda+tensorflow-gpu+pycharm)
  17. itext7读取pdf 中文_pdf转为excel表
  18. php表格中的caption,html中caption标签的使用方法及实例详解
  19. Java-Excel报表开发POI(含POI保护工作表功能)
  20. 产品经理的私房菜 - 腾讯产品模型 - 沟通能力篇

热门文章

  1. Snow Whispering
  2. R语言【Shapiro-Wilk 检验、chisq.test() 函数、ks.test() 函数】
  3. python入门指标_【邢不行|量化小讲堂系列18-Python量化入门】简易波动指标(EMV)策略在A股的实证...
  4. 企业不做网站建设会有哪些损失?
  5. 看全栈JS开发如何在60天 web3 安全审计中获得2.5万美元赏金
  6. 闲鱼确认收货后台搭建
  7. 计算机科学与技术的最高奖项,2019“中国人工智能科技最高奖”公布,哪些高校获奖项目多?...
  8. html ul 实现下拉,JavaScript实现下拉列表
  9. 创新实训——飞讯(六)
  10. STM32串口通讯数据丢失原因分析及解决办法