为什么使用数据库?
为了持久化将内存中的数据保存在硬盘上加以"固化"

1.去重
第一种 select distinct id from user;
第二种 select distinct id ,name from user;
查什么就在后面继 不能放前面
2.空值参与运算
他利用ifnull来进行操作 如果你是null 他就会变成0 如果不加这个 你直接运算null 结果还是空

3.着重号 ``
如果你有关键词 就在这个单词上面加 ` ` 号

4. and 优先级高于 or
5.包含 between
比如查询工资只要3000-5000 就可以用 between 3000 and 5000
not between(不包含)
6.占位符 _
这个比如你要查询第二字母是a的 你可以
select * from user where name like '_a%'
7.分页
多少条 pagesize
第几页 pagenum
公式(pageNum-1)*pagesize
8.声明顺序
select
from
where and/or/ not
order by desc/asc
having
limit
9. offset 偏移量(8.0新特性)
比如你要查询第32 33 条记录
select * from user limit 2(表示2记录)offset 偏移2个
10.排序 order by 及二级查询
select * from user order by age desc (一级查询),code asc (二级查询)
如果还有三级 等等 在后面继续 ,条件 就可以了
11. 正则 regexp 长度 length

12.笛卡尔积
交叉连接
他的作用就是可以把毫无相关的也能进行连接 任何一张表都可以进行连接
不需要join 直接from 后面用,隔开 两个表名 名称太长可以取别名

13.基本函数

14.if


15.ifnull

16.拼接
为了好看可以加 ,

17.日期

18.count(*) count(1) count(字段)效率区别
在myisam储存引擎这三种效率都相同
在innodb储存引擎就是三者都不一样count(*)=count(1)>count(字段)
