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

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: (view raw, whole thread or download thread mbox)
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.


In response to


pgsql-es-ayuda by date

Next:From: Max SorribasDate: 2008-02-27 15:56:16
Subject: configuracion del server PostgreSQL
Previous:From: Alvaro HerreraDate: 2008-02-27 15:22:12
Subject: Re: Campos Booleanos

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