文章詳情頁
mysql優(yōu)化 - mysql 怎么查出近7天每日的數(shù)據(jù)?
瀏覽:114日期:2022-06-19 13:16:37
問題描述
表里有個(gè)字段紀(jì)錄每次點(diǎn)擊的時(shí)間,怎么查出7天每日的數(shù)據(jù)用php顯示出來,能不能一條sql語句解決呢。
問題解答
回答1:select * from xxx where click_time >= now() - interval 7 day;
如果要統(tǒng)計(jì)每天的次數(shù):
select day(create_time), count(1) from xxx where click_time >= date(now()) - interval 7 day group by day(click_time);
相關(guān)文章:
1. mysql - AttributeError: ’module’ object has no attribute ’MatchType’2. php自學(xué)從哪里開始?3. javascript - 百度echarts series數(shù)據(jù)更新問題4. MySQL客戶端吃掉了SQL注解?5. 求大神幫我看看是哪里寫錯(cuò)了 感謝細(xì)心解答6. javascript - JS設(shè)置Video視頻對象的currentTime時(shí)出現(xiàn)了問題,IE,Edge,火狐,都可以設(shè)置,反而chrom卻...7. javascript - 圖片能在網(wǎng)站顯示,但控制臺(tái)仍舊報(bào)錯(cuò)403 (Forbidden)8. python小白的基礎(chǔ)問題 關(guān)于while循環(huán)的嵌套9. phpstady在win10上運(yùn)行10. python - Django分頁和查詢參數(shù)的問題
排行榜

熱門標(biāo)簽