dbTalk Databases Forums  

Multiple Inner and Left Joins

comp.databases.oracle comp.databases.oracle


Discuss Multiple Inner and Left Joins in the comp.databases.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alastair Williamson
 
Posts: n/a

Default Multiple Inner and Left Joins - 03-03-2009 , 06:17 AM






Hello,

I am trying to find the correct sql query syntax to join multiple tables
together including at least two left joins. I have 1 master table which
inner joins to 4 tables and then left joins to 2. The inner joins are
obviously no problem but I can only get one of the left joins working.

Does anyone have a working example of a query with such a join in it?

Many thanks

Aly



Reply With Quote
  #2  
Old   
Jakub Otrzasek
 
Posts: n/a

Default Re: Multiple Inner and Left Joins - 04-19-2010 , 10:15 AM






Alastair Williamson pisze:
Quote:
Hello,

I am trying to find the correct sql query syntax to join multiple tables
together including at least two left joins. I have 1 master table which
inner joins to 4 tables and then left joins to 2. The inner joins are
obviously no problem but I can only get one of the left joins working.

Does anyone have a working example of a query with such a join in it?

Many thanks

Aly


select t.naz,t.kod_p,t.rp,
case when j.war is null then 1 else war end war,
case when j.wym_x is null then t.wym_x else j.wym_x end wym_x,
case when j.wym_y is null then t.wym_y else j.wym_y end wym_y,
case when j.wym_z is null then t.wym_z else j.wym_z end wym_z,

case when j.wag_n is null then t.wag_n else j.wag_n end wag_n,
case when j.wag_b is null then t.wag_b else j.wag_b end wag_b,
t.kod_3,t.kod_2
from interface.imperr
inner join tow@PROD t on
err_what = 1002 and err_errid=0
and t.kod_2 = err_whatid and
err_system = t.kod_3
left outer join tow_jm@PROD j on
j.tow_kod = t.kod and
j.cjm = 'Opakowanie' and
--t.wsk_d='T' and akt='T' and
t.kod_3 in (1,2)
left outer join interface.imptwr_iface i on
twr_numer =t.kod_2 and
twr_System = t.kod_3
where twr_numer is null;

regards
j.

Reply With Quote
Reply




Thread Tools
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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.