Reputation: 1789
I have 2 tables with different num rows and I have volumns vote_up this value is different for every row in 2 tables. I need to union 2 tables and order by max vote_up value. Here is my try, but get just 1 result:
SELECT name, vote_up
FROM (
SELECT name, vote_up
FROM comments
UNION ALL
SELECT name, vote_up
FROM replays ) T
ORDER BY MAX(vote_up) DESC
Upvotes: 0
Views: 85
Reputation: 93724
Looks like you just need to order
the result in Vote_up DESC
order and you don't want to filter any rows so remove Max
from order by
SELECT name, vote_up
FROM
(
SELECT name, vote_up
FROM comments
UNION ALL
SELECT name, vote_up
FROM replays
) T
ORDER BY vote_up DESC
Upvotes: 1