个人笔记,不定期更新
2018-01-06
2018-01-17
- 添加排序
select @:=@+1 as rank, 表名称.* from 表名称 ,(select @:=0) r;
- 复制旧表数据到新表(表结构不同)
insert into 新表(字段1,字段2,.......) select 字段1,字段2,...... from 旧表
- 分组求和
select 列名1,sum(列名2) from 表名 group by 列名1
2018-03-07
select DATE_FORMAT(列名,'%m-%d %H:%i:%s') from table
2018-03-15
select * from
(select sum(backer_money) as moneyNum,
count(distinct(user_id)) as peopleNum,
DATE_FORMAT(pay_time,'%m-%d') as date
from strawberry
group by DATE_FORMAT(pay_time,'%m-%d')
desc limit 8) aa
order by date asc;
网友评论