Re: Getting Newest
| From: | Stephen | Date: | Thu, 07 Nov 2002 02:57:03 +0000 |
| Subject: | Re: Getting Newest | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123097@lists.php.net to get a copy of this message | ||
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
>
>