Mysql中的查询语句
2016-04-23 20:56
537 查看
(1)max最大值、min最下值、avg平均值、sum总数、count统计
例:select min(stuNo) from students;
(2)模糊查询(%表示任意值,_表示单个字符)
例:select * from students where stuNo like '13?';
(3)in(a,b,c)a,b,c中任意一个值
例:select * from students where stuNo in(123,134,345);
(4)between 值1 and 值2 ,表示在值1和值2之间(可以是值1和值2)
select stu_Id from students where stu_id between 5 and 10;
(5)分组查询 group by havaing
select * from students group by job having money<1000;
(6)排序(asc 升序,desc 降序)
select * from students order by stuNo asc;
(7)分页查询 limit n,m 从n+1处选择m个数据
select stuId from student limit 4,5;
(8)子查询(where,from)
where查询:用第一次的查询结果作为第二次查询的条件完成查询。
from查询: 用第一次查询的结果作为一张表,完成第二次查询。
例:select min(stuNo) from students;
(2)模糊查询(%表示任意值,_表示单个字符)
例:select * from students where stuNo like '13?';
(3)in(a,b,c)a,b,c中任意一个值
例:select * from students where stuNo in(123,134,345);
(4)between 值1 and 值2 ,表示在值1和值2之间(可以是值1和值2)
select stu_Id from students where stu_id between 5 and 10;
(5)分组查询 group by havaing
select * from students group by job having money<1000;
(6)排序(asc 升序,desc 降序)
select * from students order by stuNo asc;
(7)分页查询 limit n,m 从n+1处选择m个数据
select stuId from student limit 4,5;
(8)子查询(where,from)
where查询:用第一次的查询结果作为第二次查询的条件完成查询。
from查询: 用第一次查询的结果作为一张表,完成第二次查询。
相关文章推荐
- MySQL基础2
- MySQL基础1
- mysql练习题
- MYSQL mysql.user表中权限对应的解释
- MySQL查询优化
- MySQL错误:Can't connect to
- mysql高级查询
- mysql 查看优化器重写后的sql
- mysql提示:host xxxx not allowe to connect
- 取消MySQL timestamp列默认ON UPDATE CURRENT_TIMESTAMP
- MySQL中的datetime与timestamp区别比较,以及选择方法
- mysql主从复制汇总
- 数据库 mysql 语句
- mysql 使用中文
- mysql存储过程详解
- MySql的隔离级别和锁的关系
- MySQL 数据库 练习题
- MySQL 数据库 常用函数
- mysql group_cocnat()最大限制
- 如何记录MySQL执行过的SQL语句?