query tables based on a query

From: solarsail <solarsail(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: query tables based on a query
Date: 2005-09-30 22:47:48
Message-ID: aa44f4a30509301547g69dfffcayfe2e967925657822@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a large number of tables with a common naming convention

basically:

table001, table002, table003 ... table00n

I would like to do a query across all of the tables, however I do not know
all of the tables before hand, and I do not want to manually generate a
query like

select * from table001, table002, table003

I have a query that returns the names of the tables I want to query, it is
basically like this:

select tablename from pg_tables where tablename like 'table%'

How do I do this? I've tried creating a Table Function that returns the
above set and tried to use that in a select clause, but I cant get it to
work either.

Thanks for the help

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-09-30 23:34:17 Re: EXECUTE with SELECT INTO variable, or alternatives
Previous Message Thomas F. O'Connell 2005-09-30 20:59:06 Re: EXECUTE with SELECT INTO variable, or alternatives