Jump to content

Retrieving content grouped by date


Recommended Posts

Once again, it's time to showcase my ignorance of MySQL.  Yay! :P


I have a few tables filled with different kinds of content.  These tables all have a date_added field, which is a datetime.  What I'd like to do is retrieve content from a table, and order it by date, grouped by month, like the way most blogs do it.  So, something like:


August 2010 (5)

September 2010 (11)

October 2010 (2)




I think a query like:


SELECT COUNT(*), *month and year* FROM content GROUP BY *month and year* DESC


Would be what I want, but I'm unsure how to:


1. Group by month and year

2. Obtain that month and year


Any ideas?  I feel like I'm close, but just need a nudge in the right direction.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.