From: | "Roberto M(dot) Ruiz S(dot)" <robware(dot)ruiz(at)gmail(dot)com> |
---|---|
To: | Lista PostgreSQL <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | [Fwd: Re: Ayuda sobre joins] |
Date: | 2010-01-23 13:51:48 |
Message-ID: | 4B5AFEF4.9050404@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
-------- Mensaje original --------
<table class="moz-email-headers-table" border="0" cellpadding="0"
cellspacing="0">
<tbody>
<tr>
<th align="right" nowrap="nowrap" valign="baseline">Asunto: </th>
<td>Re: [pgsql-es-ayuda] Ayuda sobre joins</td>
</tr>
<tr>
<th align="right" nowrap="nowrap" valign="baseline">Fecha: </th>
<td>Sat, 23 Jan 2010 07:08:50 -0500</td>
</tr>
<tr>
<th align="right" nowrap="nowrap" valign="baseline">De: </th>
<td>Roberto M. Ruiz S. <a class="moz-txt-link-rfc2396E" href="mailto:robware(dot)ruiz(at)gmail(dot)com"><robware(dot)ruiz(at)gmail(dot)com></a></td>
</tr>
<tr>
<th align="right" nowrap="nowrap" valign="baseline">Para: </th>
<td>mPerez mPerez <a class="moz-txt-link-rfc2396E" href="mailto:stylergarcia(at)gmail(dot)com"><stylergarcia(at)gmail(dot)com></a></td>
</tr>
<tr>
<th align="right" nowrap="nowrap" valign="baseline">Referencias: </th>
<td><a class="moz-txt-link-rfc2396E" href="mailto:c6f2c7f51001221011y78c18f57o1a6464fe772b2bba(at)mail(dot)gmail(dot)com"><c6f2c7f51001221011y78c18f57o1a6464fe772b2bba(at)mail(dot)gmail(dot)com></a></td>
</tr>
</tbody>
</table>
<br>
<br>
<pre>mPerez mPerez escribió:
> Hola a todos, quisiera que me ayuden de como es la manera mas
> eficiente de sacar una consulta, si utilizando joins, subconsultas, etc.
> Tengo tres tablas
>
> id documento fecha producto item serie
> 1 09 01/01/2009 01001 1 SERIEX1
> 1 09 01/01/2009 01001 1 SERIEX2
> 1 09 01/01/2009 01002 2 SERIEY1
> 1 09 01/01/2009 01002 2 SERIEY2
> 1 01 01/01/2009 01001 1 SERIEX3
> 1 01 01/01/2009 01002 2 SERIEY3
> 1 01 01/01/2009 01002 3 .NULL.
>
>
> *****cabecera
> id documento fecha
> 1 09 01/01/2009
> 2 01 01/01/2009
>
> *****detalle
> id item producto unidades
> 1 1 01001 2
> 1 2 01002 2
> 2 1 01001 1
> 2 2 01002 1
> 2 3 01003 2
>
> **** series
> id item producto serie
> 1 1 01001 SERIEX1
> 1 1 01001 SERIEX2
> 1 2 01002 SERIEY1
> 1 2 01002 SERIEY2
> 2 1 01001 SERIEX3
> 2 2 01002 SERIEY3
>
> Lo que deseo es que salga de la siguiente manera:
>
> id documento fecha producto item serie
> 1 09 01/01/2009 01001 1 SERIEX1
> 1 09 01/01/2009 01001 1 SERIEX2
> 1 09 01/01/2009 01002 2 SERIEY1
> 1 09 01/01/2009 01002 2 SERIEY2
> 2 01 01/01/2009 01001 1 SERIEX3
> 2 01 01/01/2009 01002 2 SERIEY3
> 2 01 01/01/2009 01003 3 .NULL.
>
> Muchas gracias por su tiempo y ayuda.
> Saludos
>
>
>
En particular, a mi también me toma el pelo fabricar la clausula FROM de
las SQL donde intervienen varias tablas, para eso me valgo del asistente
de para crear consulta de Access, es muy sencillo de utilizar (grafico)
y las clausula FROM generada, funciona perfecto en PostgreSQL.
Crea las tablas en una base de datos PostgreSQL,
crea una conexión ODBC con la base de datos,
abre una Base de datos access
Vincula las tablas de la base de datos de PostgreSQL a Access; el nombre
sugerido por en el momento de vincular las tablas es catalogo_tabla,
después de vinculadas puedes cambiar el nombre de las tablas quitando el
catalogo_ o al generar las SQL cambia el catalogo_ por catalogo.
Abre el asistente de consulta, crea la consulta gráficamente manipulando
las relaciones y y los campos, mira el SQL generado
Usa el SQL generado en PostgreSQL
A me funciona y no tengo que lidiar con los joins
Roberto M. Ruiz S.
Colombia
</pre>
</body>
</html>
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/html | 4.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Juan José (Pepe) | 2010-01-23 17:01:38 | pregunta windows 7 |
Previous Message | Xavier Guerra | 2010-01-23 13:20:58 | Re: Ayuda sobre joins |