[Fwd: Re: Ayuda sobre joins]

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">&lt;robware(dot)ruiz(at)gmail(dot)com&gt;</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">&lt;stylergarcia(at)gmail(dot)com&gt;</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">&lt;c6f2c7f51001221011y78c18f57o1a6464fe772b2bba(at)mail(dot)gmail(dot)com&gt;</a></td>
</tr>
</tbody>
</table>
<br>
<br>
<pre>mPerez mPerez escribi&oacute;:
&gt; Hola a todos, quisiera que me ayuden de como es la manera mas
&gt; eficiente de sacar una consulta, si utilizando joins, subconsultas, etc.
&gt; Tengo tres tablas
&gt;
&gt; id documento fecha producto item serie
&gt; 1 09 01/01/2009 01001 1 SERIEX1
&gt; 1 09 01/01/2009 01001 1 SERIEX2
&gt; 1 09 01/01/2009 01002 2 SERIEY1
&gt; 1 09 01/01/2009 01002 2 SERIEY2
&gt; 1 01 01/01/2009 01001 1 SERIEX3
&gt; 1 01 01/01/2009 01002 2 SERIEY3
&gt; 1 01 01/01/2009 01002 3 .NULL.
&gt;
&gt;
&gt; *****cabecera
&gt; id documento fecha
&gt; 1 09 01/01/2009
&gt; 2 01 01/01/2009
&gt;
&gt; *****detalle
&gt; id item producto unidades
&gt; 1 1 01001 2
&gt; 1 2 01002 2
&gt; 2 1 01001 1
&gt; 2 2 01002 1
&gt; 2 3 01003 2
&gt;
&gt; **** series
&gt; id item producto serie
&gt; 1 1 01001 SERIEX1
&gt; 1 1 01001 SERIEX2
&gt; 1 2 01002 SERIEY1
&gt; 1 2 01002 SERIEY2
&gt; 2 1 01001 SERIEX3
&gt; 2 2 01002 SERIEY3
&gt;
&gt; Lo que deseo es que salga de la siguiente manera:
&gt;
&gt; id documento fecha producto item serie
&gt; 1 09 01/01/2009 01001 1 SERIEX1
&gt; 1 09 01/01/2009 01001 1 SERIEX2
&gt; 1 09 01/01/2009 01002 2 SERIEY1
&gt; 1 09 01/01/2009 01002 2 SERIEY2
&gt; 2 01 01/01/2009 01001 1 SERIEX3
&gt; 2 01 01/01/2009 01002 2 SERIEY3
&gt; 2 01 01/01/2009 01003 3 .NULL.
&gt;
&gt; Muchas gracias por su tiempo y ayuda.
&gt; Saludos
&gt;
&gt;
&gt;
En particular, a mi tambi&eacute;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&oacute;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&eacute;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&aacute;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

Browse pgsql-es-ayuda by date

  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