1. 今天在查询数据的过程中遇到了一个在时间里取日期去查询的难点,最终找到方法了,在此记录一番
select * from shop_order_product_details_capital_loss where gross_margin <=44 and DATE_FORMAT(dt,'%Y-%m-%d') = '2021-07-22'
2.在数据库中批量造数据
可以通过excel的方式,先将已有的数据导出excel格式,然后在excel中去批量增加,保存后导入到数据库中就可以了
3. 排名有相同值
select name,score,rank from (select 'name',score, @rownum:=@rownum +1 as tmp , @incrnum:= case when @rowtotal = score then @incrnum when @rowtotal := score then @ rownum end as rank from (select id , 'name', score from 'score_copy' order by score desc) as a ,(select @rownum:=0, @rowtotal := null ,@incrnum:= 0) b) c where rank<=3