Left outer join with WHERE clause? - Mailing list pgsql-sql

From DI Hasenöhrl
Subject Left outer join with WHERE clause?
Date
Msg-id 002b01c1d658$4612fc40$01011eac@irina
Whole thread Raw
Responses Re: Left outer join with WHERE clause?
Re: Left outer join with WHERE clause?
List pgsql-sql
 
Hi all,
 
I have a difficult query with some INNER JOINs and LEFT JOINs.
My first questions is: Is it possible to use a WHERE clause in a LEFT JOIN or can I realize this in a SUBSELECT and
my second question is: please, can anyone show me the correct syntax for this ;-)
 
my example:
SELECT artikel.a_nr, artikel.kl_ean, artikel.kl_nr, artikel.a_aktiv, artikel.a_bez1,artikel.a_bez2,artikel.a_bez3, 
        artikel.wg_nr, artikel.ws_nr, artikel.a_vol,vartikelws.ws_bez,vartikelws.farbe_bez,warengruppebez.wg_bez,                                   warengruppebez.sp_id, produktgruppebez.pg_bez, produktgruppebez.sp_id, kontingent.sortiment,
        kontingent.k_ep, kontingent.k_aufproz, kontingent.k_aufwert,artikel.a_pfand,kontingent.k_vk, warengruppe.pg_id                          FROM (((((artikel INNER JOIN warengruppe ON artikel.wg_nr = warengruppe.wg_nr)
                  INNER JOIN warengruppebez ON warengruppe.wg_nr = warengruppebez.wg_nr) 
                  LEFT JOIN vartikelws ON artikel.ws_nr = vartikelws.ws_nr)
                  INNER JOIN kontingent ON artikel.a_nr = kontingent.a_nr)
                  LEFT JOIN (SELECT lief_nr,kl_kurzbez FROM vartikellieferantbez
                  WHERE ((f_nr)=1) ON artikel.a_nr = vartikellieferantbez.a_nr )             *this does not work
 
                  INNER JOIN produktgruppebez ON warengruppe.pg_id = produktgruppebez.pg_id 
                  WHERE (((warengruppebez.sp_id)='D') AND ((produktgruppebez.sp_id)='D') 
                  AND ((kontingent.sortiment)='2001') AND ((artikel.ws_nr)=1));
      
It doesn't work too:            
     LEFT JOIN (vartikellieferantbez ON artikel.a_nr = vartikellieferantbez.a_nr WHERE ((vartikellieferantbez.f_nr)=1)
 
Please can anyone give me a hint.
Many thanks in advance
Irina
 
 
 
 
 

pgsql-sql by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: psql and password
Next
From: "Dan Langille"
Date:
Subject: Re: Left outer join with WHERE clause?