所以我有1个查询可以将2个评级数合并为一个
SELECT (SELECT SUM(rating) FROM " . PREFIX . "_post_extras WHERE user_id ='{$row['user_id']}') + (SELECT SUM(rating) FROM " . PREFIX . "_comments WHERE user_id ='{$row['user_id']}') AS rating
如何更改我的查询,以便postextras和postcomments中的评分是第一个请求中的评分?并按共同评级排序?
这是我的查询,我无法改变:没有来自表_comments的评级,但我也需要它。
SELECT dle_users.user_id, dle_users.user_group, dle_users.name, dle_users.foto, SUM(dle_post_extras.rating) as rating
FROM dle_users
JOIN dle_post_extras ON dle_post_extras.user_id = dle_users.user_id
WHERE dle_post_extras.rating > '0'
GROUP BY dle_users.user_id
ORDER BY dle_post_extras.rating
DESC LIMIT 0,10