cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Please excuse the poor readability, i couldn't figure out how to make underscores show up consistently. I'm using ASA 11 build 2331, 64 bit WinServ 2008.

This first select works ( it returns 6 rows as expected ). Note that e.moved-to-payment-history is part of the left outer join but e.moved-to-payment-history does NOT exist in the oh table.

SELECT oh.c1, oh.c2, oh.c3, oh.c4, c.c1, e.moved-to-payment-history   
  FROM customer c join order-header oh on c.customer-id = oh.customer-id  
    left outer join eft-payment-history e on oh.invoice-number = e.invoice-number  
                    and e.moved-to-payment-history = 'n'  
 WHERE oh.open-amount <> 0  
    and c.customer-id = '12345'

This select does NOT work ( no rows returned ). This is the SQL that I expected to work ( converted from tSQL *=, see below ). Note that e.moved-to-payment-history is in the WHERE

SELECT oh.c1, oh.c2, oh.c3, oh.c4, c.c1, e.moved-to-payment-history   
  FROM customer c join order-header oh on c.customer-id = oh.customer-id  
    left outer join eft-payment-history e on oh.invoice-number = e.invoice-number  
   WHERE oh.open-amount <> 0  
    and e.moved-to-payment-history = 'n'  
    and c.customer-id = '12345'

If I use the "old" tSQL *= this select also works ( 6 rows returned )

SELECT oh.c1, oh.c2, oh.c3, oh.c4, c.c1, e.moved-to-payment-history   
  FROM customer c, order-header oh, eft-payment-history e 
   WHERE c.customer-id = oh.customer-id  
        and oh.invoice-number *= e.invoice-number  
        and oh.open-amount <> 0  
    and e.moved-to_payment-history = 'n'  
    and c.customer-id = '12345'

I've been SLOWLY converting PowerBuilder datawindows from *= to LOJ syntax. What puzzles me is the SQL I expected to work doesn't, and the LOJ that I didn't expect to work does. Explanations from a GURU would be helpful.

View Entire Topic
Former Member

Long ago I wrote a whitepaper on TSQL outer join semantics, which includes ISO SQL-standard equivalents. You may find it helpful.

t1950
Participant
0 Likes

Thank you for the white paper.
I'm passing it on to the other programmers I work with.