Skip site navigation (1) Skip section navigation (2)

Re: Range queries with multiple tables

From: Adam Ruth <adamruth(at)mac(dot)com>
To: Mag Gam <magawake(at)gmail(dot)com>
Cc: PostgreSQL List - Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Range queries with multiple tables
Date: 2009-05-11 12:36:49
Message-ID: 5DEFB9A2-15BF-46F8-902C-68193E551BC0@mac.com (view raw or flat)
Thread:
Lists: pgsql-novice
You can use union:

select id, ts, value from 2009.01
union
select id, ts, value from 2009.02
union
select id, ts, value from 2009.03
union
select id, ts, value from 2009.04

On 11/05/2009, at 10:11 PM, Mag Gam wrote:

> I have 5 tables like named this:
>
> 2009.01
> 2009.02
> 2009.03
> 2009.04
> 2009.05
>
> Each table has a columns like this:
>
> ( id integer,
> ts timestamp,
> value char(50)
> );
>
>
> If I would like to search from 2009.01 to 2009.04 is it possible to
> build a query like that? I was thinking if there is a clever VIEW I
> can create that would include all 5 tables as 1 table.
>
> Any thoughts or ideas?
>
> TIA
>
> -- 
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice


In response to

pgsql-novice by date

Next:From: Neil SaundersDate: 2009-05-11 14:45:23
Subject: Statistics collection - Which options for which views? (8.2.4)
Previous:From: Mag GamDate: 2009-05-11 12:11:48
Subject: Range queries with multiple tables

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group