Re: Selecting from two unrelated tables - Mailing list pgsql-general

From Bricklen Anderson
Subject Re: Selecting from two unrelated tables
Date
Msg-id 45119D28.3080401@presinet.com
Whole thread Raw
In response to Selecting from two unrelated tables  (CSN <cool_screen_name90001@yahoo.com>)
List pgsql-general
CSN wrote:
> I have two tables:
>
> items: id, title, added, ...
> news: id, headline, datetime, ...
>
> I'd like to select the latest 25 combined records from both tables. Is there a way to do this
> using just select?
>
> Thanks,
> csn
>

Maybe something like this?

select id,title_headline,dt
from (
   select id,title as title_headline,added as dt from ...
   union all
   select id,headline as title_headline,datetime as dt from ...) as a
order by dt limit 25;

pgsql-general by date:

Previous
From: CSN
Date:
Subject: Selecting from two unrelated tables
Next
From: John Sidney-Woollett
Date:
Subject: Re: Selecting from two unrelated tables