Re: Selecting from two unrelated tables

Поиск
Список
Период
Сортировка
От Bricklen Anderson
Тема Re: Selecting from two unrelated tables
Дата
Msg-id 45119D28.3080401@presinet.com
обсуждение исходный текст
Ответ на Selecting from two unrelated tables  (CSN <cool_screen_name90001@yahoo.com>)
Список 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 по дате отправления:

Предыдущее
От: CSN
Дата:
Сообщение: Selecting from two unrelated tables
Следующее
От: John Sidney-Woollett
Дата:
Сообщение: Re: Selecting from two unrelated tables