 <p>After several formatting errors and incorrect / missing inline table aliases...</p> <pre><code>SELECT * FROM ( SELECT TIME FROM table1 UNION ALL SELECT TIME FROM table2 ) B WHERE TIME = ( SELECT MAX(TIME) FROM ( SELECT TIME FROM table1 union all SELECT TIME FROM table2) a ) </code></pre>