Let join syntax

From: "Nicolas JOUANIN" <n(dot)jouanin(at)regie-france(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Let join syntax
Date: 2003-06-16 10:34:34
Message-ID: CEEJJOCKHCPFNIOMMIDFGECICHAA.n.jouanin@regie-france.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I've a problem with the following query. I want to left join table sec (x5)
with x0, and x4. I try the following query :

select x0.coh_agent ,x0.bra_id ,x0.dpr_id ,x0.usr_id ,x0.csc_id
,x0.spp_id ,x0.csc_id_inv ,x0.coh_doc_inv ,x0.coh_d_inv ,
x0.coh_process ,x0.coh_doc_main ,x0.coh_status ,x0.coh_total_local
,x0.coh_basis_local ,x0.coh_cost_local ,x0.coh_profit_local
,x0.coh_over_local ,x0.coh_com_earned ,x0.coh_com_adjust
,x0.coh_com_held ,x0.coh_com_cancel ,x0.coh_com_topay ,x0.coh_d_paid
,x0.coh_matchname ,x0.coh_cscmatch ,x0.coh_com_paid ,x3.cur_dec_nb
,x3.cur_location ,x3.cur_negative ,x3.cur_dec_char ,x3.cur_group_char
,x5.sec_id ,x1.cpy_id ,x1.cpy_cr_tr ,x1.cpy_cr_tg ,x1.cpy_cr_tb
,x2.bra_screen ,x2.bra_id ,x2.lng_id ,x4.tad_cpy_name from
coh x0 , cpy x1 ,bra x2 ,
cur x3 ,tad x4 LEFT OUTER JOIN sec x5 on x5.thr_id=x4.thr_id AND
x5.usr_id=x0.usr_id AND x5.bra_id = x0.bra_id AND x5.dpr_id = x0.dpr_id,
dpr x6 where ((((((((((x0.cpy_id = x1.cpy_id ) AND (x0.bra_id
= x2.bra_id ) ) AND (x0.cur_id = x3.cur_id ) ) AND (x0.dpr_id
= x6.dpr_id ) ) AND (x2.tad_id = x4.tad_id ) ) AND (x5.thr_id
= x4.thr_id ) ) AND (x2.bra_id = x6.bra_id ) ) AND (x5.usr_id
= x0.usr_id ) ) AND (x5.bra_id = x0.bra_id ) ) AND (x5.dpr_id
= x0.dpr_id )

Unfortunatelly, postgres returns me the following error :
Error: ERROR: Relation "x0" does not exist (State:S1000, Native Code: 7)
I tried to modify the FROM sentence by:
FROM (coh x0 , cpy x1 ,bra x2 , cur x3 ,tad x4 )
LEFT OUTER JOIN sec x5 on x5.thr_id=x4.thr_id AND x5.usr_id=x0.usr_id AND
x5.bra_id = x0.bra_id AND x5.dpr_id = x0.dpr_id,

but I get a syntax error , may be due to parentheses.
Does anyone knows how to write this query correctly ?

Regards, Nicolas.
---------------------------------------------------------------
Nicolas JOUANIN - SA REGIE FRANCE
Village Informatique BP 3002
17030 La Rochelle CEDEX
Tel: 05 46 44 75 76
Fax: 05 46 45 34 17
email: n(dot)jouanin(at)regie-france(dot)com
Web : www.regie-france.com
---------------------------------------------------------------

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Manfred Koizar 2003-06-16 10:57:37 Re: Let join syntax
Previous Message David Pradier 2003-06-16 07:27:40 Re: How to make a IN without a table... ?