Sort the results of a query according to the results of another

0

I happen to have two tables, articles and likes . In the first, I keep a series of articles, and in the second, I keep the reaction of users to these articles.

I want to sort the articles (article table) in order from most to least reaction (likes table). Where the only equal value that both will share would be an ID.

Let me explain:

Table Article:

  • ID: 01 | Content: Host
  • ID: 02 | Content: Host again
  • ID: 03 | Content: Stay again more

Table Likes:

  • ID: 01 | Likes: 20
  • ID: 02 | Likes: 70
  • ID: 01 | Likes: 10

I would like to know how to make this query. Sorry if I did not know how to explain well heheh

    
asked by Omar Aristides 18.01.2017 в 01:40
source

1 answer

1

Greetings, Below I leave the query you need.

    Select A.ID, A.Content, B.Likes from Article A, Likes B where A.ID = B.ID 
group by A.ID, A.Content, B.Likes
order by B.Likes desc
    
answered by 18.01.2017 / 04:16
source