my first post...
I have a news story table where users flag stories, in priority 1,2,3,4 for displaying on the website home page.
The problem is that as they add stories the old ones get pushed down onto page two, three etc, in the CMS. They then flag a new "1", "2" etc, without clearing the old 1s, 2s etc - which remain in the data, just in case the new number 1, gets "demoted" (the flag removed) or deleted.
What I want to get out is the newsid and headline, of most recent of each number "1", "2", "3" and "4".
I have found some similar posts, but its not the timestamp that's important its the flag field (called "xorder"). The relevant fields in the "newsStories" table are below:
newsid int
headline varchar(60)
xorder int (number or null)
xtimestamp datetime - this is the publish date
In this scenario the xtimestamp field is important as its the date/time they want the news story to appear (the publish date) rather than a timestamp field, which would be updated by MySQL. We don't want to show stories where the published date/time is greater than the current system timestamp (allows stories to be embargoed) We generate the query when the web page loads, so our criteria reads something like:
where xorder IS NOT NULL
AND xorder > 0
AND xtimestamp <= 201604271800 (for 6pm today)
(This is slightly simplified as there are other criteria).
I am sorting by xtimestamp desc and xorder asc, and just getting the first 4 records found, but this is not giving them in the correct xorder.
Hope this makes sense, any help appreciated.