You can use the GREATEST function :
SELECT GREATEST((SELECT MAX(column)
FROM TABLE_1),
(SELECT MAX(column)
FROM TABLE_2))
Using UNIONs:
SELECT MAX(col)
FROM (SELECT col FROM TABLE_1
UNION ALL
SELECT col FROM TABLE_2)
Use UNION ALLfor this - faster, because it does not remove duplicates, and it doesn't matter if duplicates are returned by a subquery in this example.
source
share