有很多做法...我比較會用的是...
例如:
TableA --> ColumnA --> 型別DATETIME
TableB --> ColumnB --> 型別DATETIME
TableC --> ColumnB --> 型別DATETIME
<pre class="c" name="code">SELECT A.ColumnA
FROM TableA A, TableB B, TableC C
WHERE A.ColumnA > B.ColumnB
AND A.ColumnA > C.ColumnC
UNION
SELECT B.ColumnB
FROM TableA A, TableB B, TableC C
WHERE B.ColumnB > A.ColumnA
AND B.ColumnB > C.ColumnC
UNION
SELECT C.ColumnC
FROM TableA A, TableB B, TableC C
WHERE C.ColumnC > A.ColumnA
AND C.ColumnC > B.ColumnB
實務上, Table結構不會這麼簡單, Where條件要仔細下好.
select max(cdate) as max_date from (
select t1.date1 as cdate from table t1
union all
select t2.date2 as cdate from table t2
union all
select t3.date3 as cdate from table t3
)