SQL get value from multiple tables and then order it
I want to do a MySQL query. I have 4 tables : A, B, C, D.
I want to get common value : "wins" from all 4 tables WHERE "account" = 1
and then order it by most "wins". And all ordered "wins" LIMIT to 3 .
I will be really glad, if u help me.
I tried something like this :
SELECT o.*
FROM (
(SELECT wins FROM 'A')
UNION ALL
(SELECT wins FROM 'B')
UNION ALL
(SELECT wins FROM 'C')
UNION ALL
(SELECT wins FROM 'D')
UNION ALL
(SELECT * FROM 'A'
WHERE
account=1)
) AS o
ORDER BY wins DESC
but this is really wrong.
No comments:
Post a Comment