MySQL Finding months with data
Jul 08, 2009 Author: SQLmaster
I was started coding some small project blog. For project i needed one section archive sorted by month , but also i needed to show months only having having posts.
Easiest and faster way is to get this data with MYSQL query :
SELECT YEAR(date) as yr, MONTH(date) as mth, COUNT(*) as blogs FROM blog GROUP BY yr, mth HAVING blogs > 0;