hey everybody,
i am trying to build a query and just can't quite get my head around it. I need to display press releases from a database, but, They need to be grouped by year, then display all the months. The data will be one press release per month, the date will be a datetime column called "created_at" and here is a visual example of how i want the output. e.g:
2010
january
february
march
etc..
2009
january
february
etc..
any help would be greatly appreciated!
group mysql results by year, list months
Moderator: General Moderators
-
invisibled
- Forum Contributor
- Posts: 112
- Joined: Sun Apr 29, 2007 3:35 pm
- Location: New Westminster
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: group mysql results by year, list months
ORDER BY the date descending. Then as you loop through the results -- when the year or month changes -- insert the proper heading.
(#10850)