Jump to content

Retrieving content grouped by date


KevinM1

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)

 

etc.

 

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
https://forums.phpfreaks.com/topic/198385-retrieving-content-grouped-by-date/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.