[pgsql-ayuda] join

Jesus Aneiros aneiros@jagua.cfg.sld.cu
Sat, 18 Nov 2000 12:06:00 -0500 (EST)


On Sat, 18 Nov 2000, Jesus Aneiros wrote:

> 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;

Lo de abajo creo que sobra.

> 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@tlali.iztacala.unam.mx
> > text   : unsubscribe pgsql-ayuda
> > 
> 
> --
> Jesus Aneiros Sosa
> mailto:aneiros@jagua.cfg.sld.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@tlali.iztacala.unam.mx
> text   : unsubscribe pgsql-ayuda
> 

--
Jesus Aneiros Sosa
mailto:aneiros@jagua.cfg.sld.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@tlali.iztacala.unam.mx
text   : unsubscribe pgsql-ayuda