I have another MySQL problem. Again, with the complex queries I'm in over my head.
On my website I currently display the last 5 reviewed games on the main page. Now, it's been ticking over a while and I've decided to add news items as well to the same page.
But, I want to change the system that I have into one that displays news entries as well as reviews - showing the last entry that was posted in either category. Both tables are completely unrelated (news, review).
The following columns are what I want to be returned:
news.newsTitle
news.newsBody
news.postedOn (timestamp)
review.postedOn (timestamp)
review.reviewSummary
review.ourScore
game.gameName
game.gameImage
The game table is connected to the review table with gameID, but neither of these tables are associated with the news table.
The current query is this:
SELECT news.newsTitle, news.newsBody, DATE_FORMAT( review.postedOn, '%M %d, %Y' ) AS reviewPosted, DATE_FORMAT( news.postedOn, '%M %d, %Y' ) AS newsPosted, game.gameID, gameName, gameImage, review.reviewSummary, review.ourScore
FROM game
LEFT JOIN news ON news.newsID = news.newsID
LEFT JOIN review ON game.gameID = review.gameID
WHERE game.isPublished = 'y'
ORDER BY game.gameID DESC
LIMIT 0 , 5
But all this does is display the news item 5 times along with the game information.
Any assistance would be much appreciated.