Home > Backend Development > PHP Tutorial > 求教一个数据库有关问题,有张表,里面有每天存入的数据,如何取出每个月数据的条数

求教一个数据库有关问题,有张表,里面有每天存入的数据,如何取出每个月数据的条数

WBOY
Release: 2016-06-13 12:27:05
Original
856 people have browsed it

求教一个数据库问题,有张表,里面有每天存入的数据,怎么取出每个月数据的条数。
这是ec_ip_article表,iptime是每天的时间戳。有没有简便一点的方法,不想每个月一条条sql取出来,然后再count得出数目,那样sql太多了。

------解决思路----------------------

select FROM_UNIXTIME(iptime,'%Y-%m') as m, count(*) as cnt from ec_ip_article group by 1
Copy after login

------解决思路----------------------
<br />select FROM_UNIXTIME(iptime,'%Y%m%d'),count(0) from ec_ip_article group by FROM_UNIXTIME(iptime,'%Y%m%d')<br />
Copy after login
Copy after login

------解决思路----------------------
引用:
<br />select FROM_UNIXTIME(iptime,'%Y%m%d'),count(0) from ec_ip_article group by FROM_UNIXTIME(iptime,'%Y%m%d')<br />
Copy after login
Copy after login


select FROM_UNIXTIME(iptime,'%Y%m'),count(0) from ec_ip_article group by FROM_UNIXTIME(iptime,'%Y%m')
------解决思路----------------------
<br />SELECT ip_id,count(ip_id) count,FROM_UNIXTIME(iptime, '%Y%m%d') date FROM test GROUP BY FROM_UNIXTIME(iptime, '%c') ORDER BY iptime<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template