一、select all/distinct 字段名/别名 from table where条件+【1】+【2】+【3】;

where条件:>,<,≥,≤,like,between and(闭区间),in ,not in,与&&,或||,非!

all:查询去全部

distinct:去掉重复的结果

【1】:group by 【asc/desc】   asc:升序,desc:降序

【2】:order by

【3】:limit           limit 3:取前3条记录;limit 2,3:从第三条记录开始,共取3条记录(从位置2开始,length为3)----可以用来分页

1、举例演示

先建一个表,id为主键(primary key),且自增长(auto_increment)

create table testabc (id int primary key auto_increment,name varchar(4));

添加数据

insert into testabc set name='a';

批量添加

insert into testabc (name) values ('a'),('b'),('c'),('c'),('a'),('a');

select * from testabc where name='a';

select * from testabc group by name;

限制前3个 select * from testabc limit 3;

select * from testabc limit 2,3; 从第三条记录开始,共取3条记录(从位置2开始,length为3)

二、常用函数max(),min(),avg(),count(),count()---记录值为NULL时不统计入数

1、举例演示,表如下

select max(age) from stu;

select sex, count(*) from stu group by sex;

select sex,count(*),max(age),avg(age) from stu group by sex;

最新文章

  1. Python-Mac 安装 PyQt4
  2. 高亮 TRichEdit 当前行
  3. Tomcat 安装--小白教程
  4. sql: sq_helptext
  5. asp.net 中json字符串转换
  6. 人生规划和GTD——“知”、“得”与“合”
  7. Linux shell入门基础(七)
  8. [CSS] CSS Transitions: Delays and Multiple Properties
  9. 手机端 UI一些插件
  10. JAVA FILE or I/O学习 - File学习
  11. 彻底卸载 postgreSQL .etc
  12. Oozie安装时放置Mysql驱动包的总结(网上最全)
  13. Zernike不变矩
  14. mysql数据库基本使用(增删改查)
  15. mongodb 集群分片
  16. TCP连接建立系列 — 客户端的端口选取和重用
  17. qt之fiddler抓包
  18. 使用js获取页面参数
  19. 单列模式,装饰器、new方法、类/静态方法实现单列模式
  20. PHUML 生成UML类图操作流程

热门文章

  1. Linux常用目录及目录作用说明
  2. Leetcode题目101.对称二叉树(简单)
  3. yum异常: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
  4. TCP拥塞控制算法
  5. mac mysql重置root用户密码
  6. 【Webscraper】不懂编程也能爬虫
  7. layer.js错误Uncaught TypeError: i is not a function
  8. 齐普夫-Zipf定律
  9. C#实现MJPEG服务器
  10. LC 813. Largest Sum of Averages