Answer the question
In order to leave comments, you need to log in
MySQL query with sort on two tables?
Hello! Please help me write a MySQL query correctly.
There are two tables.
users:
1. user_id
2. name
3. rating (int)
4. place (int)
subscribes (подписки на пользователей):
1. from_user_id (кто подписался)
2. to_user_id (на кого подписался)
SELECT subscribes.to_user_id, count(subscribes.to_user_id) as cnt, users.*
FROM subscribes, users
WHERE users.user_id = subscribes.to_user_id
GROUP BY subscribes.to_user_id
ORDER BY users.rating DESC, cnt DESC, users.place ASC
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question