Unix Technical Forum

Re: problem while converting sybase quries to postgres

This is a discussion on Re: problem while converting sybase quries to postgres within the pgsql Sql forums, part of the PostgreSQL category; --> Please cc: the list when you reply to me - that way others can help too. imam wrote: >>If ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 10:55 AM
Richard Huxton
 
Posts: n/a
Default Re: problem while converting sybase quries to postgres

Please cc: the list when you reply to me - that way others can help too.

imam wrote:
>>If this is a left outer join, you could do something like:
>>SELECT
>> ...
>>FROM
>> pe_pop_sr_posted_tran_head t1
>>LEFT JOIN
>> pe_pop_po_header t2
>>ON
>> t1.po_header_pk = t2.po_header_pk
>>LEFT JOIN
>> pe_pop_sr_posted_tran_det t3
>>ON
>> t2.po_header_pk = t3.po_header_pk
>> AND t1.sr_tran_head_pk = t3.sr_tran_head_pk
>>
>>But you'll want to test it because I'm not clear what your query is doing.
>>--
>> Richard Huxton
>> Archonet Ltd

>
>
> Thanking for you reply the problem is that i have a "or" condition and left
> outer join between two table.A po_header_table is comman in both the join as
> given below
> t1.PO_HEADER_PK *= t2.PO_HEADER_PK or t3.PO_HEADER_PK *=
>>>t2.PO_HEADER_PK)


Ah! Hadn't spotted that. Would this be what you're after?

SELECT ... FROM
(
SELECT
t1.po_header_pk AS t1_phpk
t3.po_header_pk AS t3_phpk
...
FROM
t1, t3
WHERE
t1.sr_tran_head_pk = t3.sr_tran_head_pk
)
AS first
LEFT JOIN
t2
ON (
first.t1_phpk = t2.po_header_pk
OR first.t3_phpk = t2.po_header_pk
)

Not sure what happens if t1_phpk and t3_phpk both match different rows
in t2 or whether that's what you want.
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:50 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com