mysql函数

条件查询

SELECT DISTINCT 字段 FROM 表; distinct 去重

select * from emp where ename like 'l%' like 通配符

select * from emp where mgr is null --过滤字段值为空的

select * from emp where mgr is null --过滤字段值为空的

select * from emp where sal<=3000 and sal>=10000--等效

select * from emp where sal between 3000 and 10000--等效

select * from emp limit 0,3 --从第一条开始,展示3条记录--前三条

SELECT * FROM emp order by sal #默认升序

SELECT * FROM emp order by sal desc #降序

聚合 aggregation

select count(*) from emp

select min(sal) min,max(sal) max from emp --最小值最大值

select sum(sal) from emp --求和

select avg(sal) from emp --平均数

select deptno, AVG(sal) from emp group by deptno #按部门分组 having AVG(sal)<8000 #查询条件,类似where,但是group by只能配合having

tuncate删除所有记录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值