MySQL查询语法 多表联查 视图 索引

1.简单查询
2.聚合函数查询
3.子查询
4.内外连接
5.三大范式
6.事务
7.视图
8.索引
9.补充内容

简单查询

1.查询所有字段 查询需要查的字段

select * from where 

2.取别名
3.条件查询
4.逻辑运算符 and / or / not
5.去重 distinct 按字段去重查询 from 表名
6.模糊查询 like %:任意个字符 _:有且仅有一个字符
7.between and 查询某个闭区间 [22,40]

查询年龄>=20 且 <=40的学生名字
select * from student where sage between 22 and 40

8.in 在什么里面 not in 不在里面

查找年龄在 18 19 21 22 的女生
select * from student where sage not in (18,19,21,22) and ssex = "女"

9.is null 查找某字段为空的数据

select * from student where ssex is null
select * from student where ssex  is not null
select * from student where not ssex  is null

10.分页查询

参数1 :从哪一条数据开始查     参数2 :需要查询的记录数
select * from student limit 0,5

11.排序查询

	默认升序 :asc   降序 :desc
select * from student order by sage asc,sid desc
select * from student order by sage desc

复杂查询 / 聚合函数查询

求最值

select max(字段名) from stu
select min(字段名) from stu

总和:sum( )

统计
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值