vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| On Mar 17, 1:40 pm, erobinso...@gmail.com wrote: > 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(updatetime) from (select updatetime from deposit union select updatetime from withdraw) |
| |||
| On Mon, 17 Mar 2008 10:59:09 -0700 (PDT), ZeldorBlat <zeldorblat@gmail.com> wrote: >On Mar 17, 1:40 pm, erobinso...@gmail.com wrote: >> 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(updatetime) >from (select updatetime from deposit > union > select updatetime from withdraw) 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 fourteen days I lost two weeks. (Joe E. Lewis) (#197) |
| ||||
| On 17 Mar, 19:02, Kees Nuyt <k.n...@nospam.demon.nl> wrote: > On Mon, 17 Mar 2008 10:59:09 -0700 (PDT), ZeldorBlat > > > > <zeldorb...@gmail.com> wrote: > >On Mar 17, 1:40 pm, erobinso...@gmail.com wrote: > >> 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(updatetime) > >from (select updatetime from deposit > > union > > select updatetime from withdraw) > > 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 fourteen days I lost two weeks. (Joe E. Lewis) (#197) Yuk. If you're gonna do that then at least do it the "proper" way with the LEFT JOINS: http://dev.mysql.com/doc/refman/5.0/...group-row.html |