sql - How do I return data from multiple MySQL tables in date order? -


I have another MySQL problem Again, with complex questions I am on my head.

On my website I display the last 5 reviewed games on the Currently homepage. Now, it has been ticking for a while and I have decided to add news on the same page.

However, I want to see the system change is one that shows news entries as well as reviews - shows the last entry that was either posted in the category . Both tables are completely unrelated (news, reviews).

The following columns are what I want to return:

  news.newsTitle news.newsBody news.postedOn (timestamp) Review.postedOn (timestamp) review.reviewSummary review. OurScore game.gameName game.gameImage  

Games table are associated with the review News table.

The current query is:

  Select News Newspaper, News. Posted, DATE_FORMAT (news posted, '% M% d,% Y'), NewsPosted, game.gameID, DATE_FORMAT (review posted, '% M% D,% Y') GameName, Game Image, Review Review summary, review game out. Include news on the news from our Tire. NewsID = News News Id Join in the game review gameID = review.gameID where game.a.gameid DESC LIMIT 0, 5  

by publishing = 'Y' order but display all news items 5 times together

You need to investigate the union - create two questions that match the same number (and equivalent) columns Output, use the union in the result and then according to the results of the top 5.

Using the above, regardless of the latest Top 5, their mix of news / reviews - is it what you mean?

The following should return the desired data:

  (SELECT news.newsTitle AS title, news.newsBody AS body, DATE_FORMAT (News posted, '% M% D,% Y '), the news was posted, as the screen, the news from the Null AS score in the form of the image) All in the Union (select title name as game.game name, review.reviewSummary AS body, DATE_FORMAT (review.postedOn, '% M% d,% Y') Posted in AS, review.postedOn, game.game Image, image as image. Leave the game from OurScore AS game And join in the game. GameID = review.gameID where Kelkprkashit = 'Y') order by mail add-on Diissi LIMIT 0,5  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -