思路1 使用UNION ALL
SELECT t.id, COUNT(t.id) AS num
FROM (
SELECT requester_id AS id
FROM request_accepted
UNION ALL
SELECT accepter_id AS id
FROM request_accepted
) t
GROUP BY t.id
ORDER BY COUNT(t.id) DESC LIMIT 1;Last updated
SELECT t.id, COUNT(t.id) AS num
FROM (
SELECT requester_id AS id
FROM request_accepted
UNION ALL
SELECT accepter_id AS id
FROM request_accepted
) t
GROUP BY t.id
ORDER BY COUNT(t.id) DESC LIMIT 1;Last updated