From: | Jesus Aneiros <aneiros(at)jagua(dot)cfg(dot)sld(dot)cu> |
---|---|
To: | pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx |
Subject: | Re: [pgsql-ayuda] join |
Date: | 2000-11-18 12:47:01 |
Message-ID: | Pine.LNX.4.10.10011180737230.6967-100000@jagua.cfg.sld.cu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Con un OUTER JOIN se resolveria
SELECT t1.c1, t1.c2, t2.c2
FROM t1 LEFT JOIN t2
ON t1.c3 = t2.c1;
Pero me temo que PgSQL todavia no soporta este tipo de acoples.
La siguiente UNION debe darte un resultado similar. (Asumiento que c1 es
llave).
SELECT t1.c1, t1.c2, t2.c2
FROM t1, t2
WHERE t1.c3 = t2.c1
UNION
SELECT c1, c2, ' '
FROM t1
WHERE c1 NOT IN (SELECT c1
FROM t1, t2
WHERE t1.c3 = t2.c1);
On Tue, 14 Nov 2000, OCR wrote:
> tengo las tablas
> t1 t2
> c1 | c2 | c3 c1 | c2
> oscar |cano | 1 1 | doctor
> juan |algo | 3 2 | maestro
> paco |xx | 3 | licenciado
>
> si hago:
> select t1.c1,t1.c2,t2.c2 from t1,t2 where t1.c3=t2.c1
> me despliega:
>
> oscar |cano | doctor
> juan |algo | licenciado
>
> pero quiero que me despliege:
>
> oscar |cano | doctor
> juan |algo | licenciado
> paco |xx |
>
> como hago esto?
> --------- Pie de mensaje -------------------------------------------
> Archivo historico: http://tlali.iztacala.unam.mx/maillist/pgsql-ayuda
> Cancelar inscripcion:
> mail to: majordomo(at)tlali(dot)iztacala(dot)unam(dot)mx
> text : unsubscribe pgsql-ayuda
>
--
Jesus Aneiros Sosa
mailto:aneiros(at)jagua(dot)cfg(dot)sld(dot)cu
http://jagua.cfg.sld.cu/~aneiros
--------- Pie de mensaje -------------------------------------------
Archivo historico: http://tlali.iztacala.unam.mx/maillist/pgsql-ayuda
Cancelar inscripcion:
mail to: majordomo(at)tlali(dot)iztacala(dot)unam(dot)mx
text : unsubscribe pgsql-ayuda
From | Date | Subject | |
---|---|---|---|
Next Message | Jesus Aneiros | 2000-11-18 17:06:00 | Re: [pgsql-ayuda] join |
Previous Message | Sandino Araico Sánchez | 2000-11-18 02:20:47 | Re: [pgsql-ayuda] Bases de datos con java |