I'm creating a website and I want to display on my main page the most recent articles that have either been created or updated. Sorted by most recent of either.
Originally I came up with
What would happen is, it would take all the "updated" entry, and display them first, regardless of if there was an entry created AFTER the most recently updated entryCode:SELECT title,text,date_format(created,'%M %e, %Y') AS cf,date_format(updated,'%M %e, %Y') AS uf FROM `journal_entries` ORDER BY `updated` DESC,`created` DESC LIMIT 0, 4
for instance, the above query would give me something like this:
as you can see row 3 should be listed 1st, followed by 1, 2, 4, 5Code:+-------------------+------------------+ | cf | uf | +-------------------+------------------+ | January 1, 2008 | April 6, 2008 | +-------------------+------------------+ | April 2, 2008 | April 5, 2008 | +-------------------+------------------+ | April 7, 2008 | NULL | +-------------------+------------------+ | April 2, 2008 | NULL | +-------------------+------------------+ | March 18, 2008 | NULL | +-------------------+------------------+
I've looked into different things like GROUP BY, MAX(), UNION, nothing seems to be working.
Any help would be appreciated! Thanks!



Reply With Quote


Bookmarks