webby
09-13-2005, 09:44 AM
I'm trying to figure out how to display articles stored in a MySQL database in the order they were either last updated or originally posted, whichever is later, and display the 5 most current results on the main page. Currently, these are two separate variables, so both "Posted" and "Updated" dates can be displayed on each article's page.
Example of what I want:
Posted: Sept 12
Updated: Sept 9
Posted: Sept 8
Posted: Sept 6
Updated: Sept 3
Could this be done in the query itself, or would I need two separate queries (SELECT...ORDER BY posted DESC LIMIT 0, 5) and (SELECT...ORDER BY updated DESC LIMIT 0, 5), then choose the 5 most current from those 10 results and integrate them with code from there? :confused:
"SELECT ... ORDER BY updated DESC, date DESC LIMIT 0, 5";
...obviously doesn't work, since it will pull updated before posted, regardless of whether something was posted after something else was updated or not.
Thanks in advance. :)
Example of what I want:
Posted: Sept 12
Updated: Sept 9
Posted: Sept 8
Posted: Sept 6
Updated: Sept 3
Could this be done in the query itself, or would I need two separate queries (SELECT...ORDER BY posted DESC LIMIT 0, 5) and (SELECT...ORDER BY updated DESC LIMIT 0, 5), then choose the 5 most current from those 10 results and integrate them with code from there? :confused:
"SELECT ... ORDER BY updated DESC, date DESC LIMIT 0, 5";
...obviously doesn't work, since it will pull updated before posted, regardless of whether something was posted after something else was updated or not.
Thanks in advance. :)