MySQL GROUP BY UNIX TIMESTAMP

I’m trying to fetch a number of rows from a MySQL database and group them by the day they were posted.

End result I would like the following..

Monday
-Article 1
-Article 2
-Article 3

Tuesday
-Article 1
-Article 2

Wednesday
-Article 1
-Article 2
-Article 3
-Article 4

And so on, I’m not sure if this can be done in MySQL alone without PHP doing extra work.

This is the query I have so far but doesn’t seem to group by day.

SELECT
cms_news.news_id,
cms_news.news_title,
cms_news.news_date,
cms_news.news_category,
cms_news.news_source,
cms_news.news_type,
cms_news.news_content
FROM
cms_news cms_news,
GROUP BY
DAYOFMONTH(FROM_UNIXTIME(cms_news.news_date))
ORDER BY
cms_news.news_date DESC

Thanks.

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

One Response to MySQL GROUP BY UNIX TIMESTAMP

  1. Narcis Radu says:

    0

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>