RE: [PHP] Getting Newest
| From: | John W. Holmes | Date: | Thu, 07 Nov 2002 03:05:01 +0000 |
| Subject: | RE: [PHP] Getting Newest | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123098@lists.php.net to get a copy of this message | ||
Read my last post and then run SELECT VERSION() in MySQL. I really doubt
you're running 4.0.
---John Holmes...
> -----Original Message-----
> From: Stephen [mailto:webmaster@melchior.us]
> Sent: Wednesday, November 06, 2002 9:57 PM
> To: PHP List
> Subject: Re: [PHP] Getting Newest
>
> Oh, well, now I'm getting this error:
>
> You have an error in your SQL syntax near 'union select * from church
> union
> select * from misc order by date desc limit 1' at line 1
>
> Here's what I did for the SQL
>
> $sql = "select * from school union ";
> $sql .= "select * from church union ";
> $sql .= "select * from misc order by date desc limit 1";
>
>
> ----- Original Message -----
> From: "John W. Holmes" <holmes072000@charter.net>
> To: "'Stephen'" <webmaster@melchior.us>; "'PHP
> List'"
> <php-general@lists.php.net>
> Sent: Wednesday, November 06, 2002 9:43 PM
> Subject: RE: [PHP] Getting Newest
>
>
> > UNION is implemented in MySQL 4.0.0, btw.
> >
> > > -----Original Message-----
> > > From: Stephen [mailto:webmaster@melchior.us]
> > > Sent: Wednesday, November 06, 2002 9:33 PM
> > > To: PHP List
> > > Subject: Re: [PHP] Getting Newest
> > >
> > > So for my SQL statement I put this?
> > >
> > > $sql = "select id, date, name, text from table1 union";
> > > $sql2 = "select id, date, name, text from table2 union";
> > > $sql3 = "select id, date, name, text from table3 order by date
desc";
> > >
> > >
> > > ----- Original Message -----
> > > From: "Nick Eby" <nick_eby@bonzidev.com>
> > > To: <php-general@lists.php.net>
> > > Sent: Wednesday, November 06, 2002 7:57 PM
> > > Subject: Re: [PHP] Getting Newest
> > >
> > >
> > > > you could make a union of all the records, and order by newest
date
> > > first:
> > > >
> > > > (select id, date, name, text from table1) union
> > > > (select id, date, name, text from table2) union
> > > > (select id, date, name, text from table3) order by date desc
> > > >
> > > > then select the first record
> > > > /nick
> > > >
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit:
> > > > http://www.php.net/unsub.php
> > > >
> > > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php