Select MAX time from multiple tables

Select MAX time from multiple tables

Post by erobinson3 » Wed, 19 Mar 2008 02:40:58


I have 2 tables:


deposit
withdraw

each table has a column named, updatetime, which is a timestamp type.

How would I use a single select to pull the most recent updatetime
from either table?

i.e., select max(updatetime) from deposit,withdraw;


Thanks,
Erob
 
 
 

Select MAX time from multiple tables

Post by ZeldorBla » Wed, 19 Mar 2008 02:59:09


select max(updatetime)
from (select updatetime from deposit
union
select updatetime from withdraw)

 
 
 

Select MAX time from multiple tables

Post by Kees Nuy » Wed, 19 Mar 2008 04:02:30

On Mon, 17 Mar 2008 10:59:09 -0700 (PDT), ZeldorBlat




or even

select max(updatetime)
from (select max(updatetime) from deposit
union
select max(updatetime) from withdraw
);
--
( Kees
)
c[_] I went on a diet, swore off drinking and heavy eating,
and in four *** days I lost two weeks. (Joe E. Lewis) (#197)
 
 
 

Select MAX time from multiple tables

Post by Captain Pa » Wed, 19 Mar 2008 19:08:30


Yuk. If you're gonna do that then at least do it the "proper" way with
the LEFT JOINS:
http://www.yqcomputer.com/