Re: Re: get row (latest by date)
| From: | Joseph W. Goff | Date: | Thu, 09 Jan 2003 15:45:57 +0000 |
| Subject: | Re: Re: get row (latest by date) | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-17734@lists.php.net to get a copy of this message | ||
Actually, mysql does not support sub-selects.
You can do this however with something like this:
select * from your_table order by date_column desc, time_column desc limit 1
----- Original Message -----
From: "Radovan Radic" <rasho@ving.co.yu>
To: <php-windows@lists.php.net>
Sent: Thursday, January 09, 2003 9:46 AM
Subject: [PHP-WIN] Re: get row (latest by date)
> select * from table where date=(select max(date) from table) and
> time=(select max(time) from table)
>
> HTH,
> Radovan
>
> "Aidal" <aidal@nospam.dk> wrote in message
> news:20030109130550.9568.qmail@pb1.pair.com...
> > Hi NG.
> >
> > I know this is probably very simple, but I've had no luck making it work
> :(
> >
> > I want 1 single row out of a table, that row must be the latest by date
> and
> > time.
> >
> > The table looks like this (example MySQL):
> > _______________________________________________
> > id | type_id | date | time | title |
> > source |
> > ---------------------------------------------------------------
> > 128 | 1 | 2003-01-09 | 15:00:52 | some title | blabla |
> > 129 | 1 | 2003-01-09 | 15:02:43 | some title 2 | blabla 2 |
> > ---------------------------------------------------------------
> >
> > What i need is the SQL that would give me the latest created row of
these
> 2
> > (i dont mean latest as in last_id) by date and time in this case the
> result
> > should be the row with id = 129 because of the time.
> >
> > Please help...
> >
> > ~ Aidal
> >
> >
> >
> >
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>