Re: SELECT from multiple tables (not join though)

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Madison Kelly <linux(at)alteeve(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT from multiple tables (not join though)
Date: 2005-01-10 18:00:47
Message-ID: 20050110180047.GA24404@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jan 10, 2005 at 12:47:53PM -0500, Madison Kelly wrote:

Madison,

> The trick now is I need to know which table each result came from. I can
> add another column and record the table number and SELECT that at the
> same time but before I do I was wondering if I can do this more
> efficiently or elegantly.

You can get the Oid of the table very easily with the "tableoid" column.
If you want the name you can use tableoid::regclass, though I'm not sure
if that works as a normal text column.

Be sure to grok the difference between UNION and UNION ALL (which is the
fact that UNION sorts and "uniqs" its input).

--
Alvaro Herrera (<alvherre[(at)]dcc(dot)uchile(dot)cl>)
Oh, oh, las chicas galacianas, lo harán por las perlas,
¡Y las de Arrakis por el agua! Pero si buscas damas
Que se consuman como llamas, ¡Prueba una hija de Caladan! (Gurney Halleck)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Madison Kelly 2005-01-10 18:08:13 Re: SELECT from multiple tables (not join though)
Previous Message Madison Kelly 2005-01-10 17:47:53 Re: SELECT from multiple tables (not join though)