I need some help with a mysql query.
I have 2 tables,
Table 1 – Photos (photo_id, photo_url)
1—– http://www.someurl.com
2—– http://www.someurl.com
3—– http://www.someurl.com
4—– http://www.someurl.com
Table 2 – Favorites (favorite_id, user_id,photo_id)
1——-5——1
2——-5——2
3——-6——1
4——-6——3
5——-7——2
6——-7——3
7——-8——3
7——-8——4
I want to get results from photos table ordering by the favorite numbers of users.
Correct ordering must be:
1) Photo-3 (3 votes)
2) Photo-2 (2 votes)
2) Photo-1 (2 votes)
2) Photo-4 (1 vote)
1 Answer