Получаем топ 10 фильмов.
SELECT *
FROM films
LEFT JOIN film_likes ON films.id = film_likes.film_id
GROUP BY films.id
ORDER BY COUNT(film_likes.user_id) DESC
LIMIT 10;
Получаем список друзей пользователя.
SELECT *
FROM users
INNER JOIN friends ON users.id = friends.friend_id
WHERE friends.user_id = ?
AND friend_status = TRUE;