1简单查询   select* from 表名

select name as“姓名”fromstu     (把name改为名字)

2条件查询 where 后面跟条件  条件要写清楚

3模糊查询  like  no like    %代表任意多个字符   _代表一个字符

4排序查询  order by 字段 排序值 (desc降 asc升)

5范围查询     between....and...

6离散查询  in  notin

7聚合查询   sun 求和   count数据条数   max最大值  min最小值 avg平均值

8分页查询 limit 从第几条开始,取多少数据

表名limit(pagesize-1)*5,5     pagesize是页数   *5 是每页条数 ,5 取多少条

9去重查询 distinct      select distinct  表段名 from 表名

10分组查询 group by 字段  having 条件

select count(*),cno,group_concat(degree),sum(degree) from score group by cno ;

select cno,group_concat(degree),sum(degree) from score group by cno having count(*)>3

#分组之后根据条件查询使用having 不使用where

高级查询

  1. 连接查询,对列的扩展

Select * from student as stu,score as sc

where stu.sno = sc.sno and sc.sno = “103” ;

2.联合查询,对行的扩展

select Code,Name from Info

union

select Code,Name from Nation

3.子查询

(1)无关子查询

外层查询 (里层查询)

子查询的结果当做父查询的条件

子查询:select Code from Nation where Name='汉族'

父查询:select * from Info where Nation = ''

select * from Info where Nation = (select Code from Nation where Name='汉族')

(2)相关子查询

查询汽车表中油耗低于该系列平均油耗的所有汽车信息

父查询:select * from Car where Oil<(该系列平均油耗)

子查询:select avg(Oil) from Car where Brand = '某个系列'

select * from Car a where Oil<(select avg(Oil) from Car b where b.Brand = a.Brand )

最新文章

  1. Elasticsearch相关资源
  2. yum使用本地源
  3. 10 位顶级 PHP 大师的开发原则
  4. Python一些难以察觉的错误
  5. c 指针兼容性问题
  6. window.print打印指定div实例代码
  7. 科研论文提交流程与常见问题(EDAS 系统提交)
  8. MySQL AB复制
  9. android脚步---使用framelayout实现霓虹灯效果
  10. CMake入门实战
  11. 配置Asp.Net Web项目NLog配置文件的位置
  12. selenium之 chromedriver与chrome版本映射表(更新至v2.43)
  13. UGUI合批原理笔记
  14. nginx的前世今生
  15. BZOJ4432 : [Cerc2015]Greenhouse Growth
  16. 对象缓冲池 ( cc.pool ) :
  17. 排错-LR安装No&#160;Background&#160;bmp&#160;defined&#160;in&#160;...的解决办法
  18. ThreadLocal可能引起的内存泄露
  19. linux 查看日志命令
  20. spring security文档地址

热门文章

  1. 【UVA】12504 Updating a Dictionary(STL)
  2. java基础循环
  3. poj2356 Find a multiple
  4. python 之 functools模块
  5. svn ignore 的用法(忽略文件及目录)
  6. Python操作中缓存Redis
  7. GeoServer之sqlserver插件使用
  8. 查看DNS服务器
  9. Linux git 关联 github仓库
  10. HTTP 状态信息