Quote:
Originally Posted by Old Pedant
Code:
SELECT MAX(U.views) FROM (
SELECT views FROM table1
UNION
SELECT views FROM table2
) AS U
You *might* get better performance from:
Code:
SELECT MAX(U.maxview) FROM (
SELECT MAX(views) AS maxview FROM table1
UNION
SELECT MAX(views) AS maxview FROM table2
) AS U
You can try it both ways.
|
It will show only one reslt, doesnt it?
And if I want to show the the top 3?
edit:
I found out how to do it and it works,
PHP Code:
$getcontent = "SELECT .. FROM
( SELECT .. FROM moviesdb
UNION ALL
SELECT ... FROM gamesdb ORDER BY views DESC LIMIT 3) views";
but I got anothing problem.
I need to check from what databse I got the result, and I have no idea how to do it and where to place the "AS" or these things.
help?