Search Postgresql Archives

Re: Selecting from two unrelated tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux