Re: Join sobre una misma tabla...

From: "Sergio Valdes Hurtado" <svh(dot)pgsql(at)gmail(dot)com>
To: "Mario Wojcik" <mariowojcik(at)yahoo(dot)com(dot)ar>
Cc: "Lista de Ayuda Postgresql" <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Join sobre una misma tabla...
Date: 2008-02-27 15:25:51
Message-ID: 9032d01f0802270725q6c3bf0er49eaaa70b3dc2f67@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

2008/2/27, Mario Wojcik <mariowojcik(at)yahoo(dot)com(dot)ar>:
> Hola Gente!
> Tengo el siguiente problema:

Prueba usando UNION, ya que el manual de Postgres dice:

The UNION clause has this general form:

select_statement UNION [ ALL ] select_statement

select_statement is any SELECT statement without an ORDER BY, LIMIT,
FOR UPDATE, or FOR SHARE clause. (ORDER BY and LIMIT can be attached
to a subexpression if it is enclosed in parentheses. Without
parentheses, these clauses will be taken to apply to the result of the
UNION, not to its right-hand input expression.)

The UNION operator computes the set union of the rows returned by the
involved SELECT statements. A row is in the set union of two result
sets if it appears in at least one of the result sets. The two SELECT
statements that represent the direct operands of the UNION must
produce the same number of columns, and corresponding columns must be
of compatible data types.

The result of UNION does not contain any duplicate rows unless the ALL
option is specified. ALL prevents elimination of duplicates.
(Therefore, UNION ALL is usually significantly quicker than UNION; use
ALL when you can.)

Multiple UNION operators in the same SELECT statement are evaluated
left to right, unless otherwise indicated by parentheses.

Currently, FOR UPDATE and FOR SHARE cannot be specified either for a
UNION result or for any input of a UNION.

Por lo que teoricamente debería poder hacerse las dos consultas sobre
la misma tabla, pero con distintos parámetros.

saludos

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Max Sorribas 2008-02-27 15:56:16 configuracion del server PostgreSQL
Previous Message Alvaro Herrera 2008-02-27 15:22:12 Re: Campos Booleanos