Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Go Back   Foros Club Delphi > Principal > SQL
Register FAQ Members List Calendar Guía de estilo Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03/02/2005
santi santi is offline
Miembro
 
Join Date: Jan 2005
Posts: 16
Poder: 0
santi Va por buen camino
Outer Join

Hola a tod@s,
necesito hacer una join de dos tablas que me muestre el resultado tanto si los registros de la izquierda son nulos como los de la derecha.
Necesitaría algo del tipo ..WHERE tabla1.campo(+) = tabla2.campo(+), pero así no funciona. Hay otra manera de escribirlo?
Gracias.
Santi.
Reply With Quote
  #2  
Old 03/02/2005
Neftali [Germán.Estévez]'s Avatar
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Join Date: Jul 2004
Location: Barcelona - España
Posts: 19,449
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
En una sólo consulta no se si vas a poder; Se me ocurre que puedes hacer una UNION. El la primera utilizas INNER JOIN (te devolverá los que no son nulos en ninguna de las dos) y en la segunda utilizas un WHERE para los que son nulos en una tabla y en la otra (sin JOIN, para que haga el producto cartesiano). No lo he probado, pero creo que debe funcionar.

Código SQL [-]
 SELECT T1.*, T2.* FROM ... T1 INNER JOIN T2 ON...
 UNION
 SELECT T1.*, T2.* FROM ... T1,T2 WHERE (not T1.campo IS NULL) or (not T2.campo IS NULL)

...algo así.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Reply With Quote
  #3  
Old 03/02/2005
santi santi is offline
Miembro
 
Join Date: Jan 2005
Posts: 16
Poder: 0
santi Va por buen camino
Gracias, lo he probado y funciona!!!
Santi.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +2. The time now is 21:11.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi