Hi all, I'm struggling to find a single MySQL query for what I am trying to do. I've got a table that contains News posts that looks something like this:
Code:
[u]News:</u>
newsID int(11)
post text
startDate timestamp
endDate timestamp
The startDate and endDate times are used to specify how long the post is displayed on my website.
To archive these posts I want to find every month that had posts appearing in it and a count of the number of posts that it had. For example, if 3 different news posts appear sometime during October 2003, and 2 during September, then I need the MySQL query to return:
'October 2003' and '3'
'September 2003' and '2'
It gets tougher. The startDate and endDate of a news post can span multiple months and so if the startDate was in August and the endDate was in October for a particular news post I would need that to be counted as 1 for August, September, and October.
Is this at all possible to do with a single query? I'm not sure. I was thinking that an extra table that simply contains months might help.
I'm using "mysql Ver 12.20 Distrib 4.0.13, for pc-linux"
and PHP 4.0.6 if that helps.
Anyway, if anyone thinks they can help out, that would be friggin awesome and much appreciated. Thanks in advance!
BTW: If any one can answer this for me, I'll give them some killer FTP access. Just a little incentive :)