Toad World® Forums

Left outer join

B.JUR_CODE

A.NAME,

FROM DLSGATEWAY.JURISDICTION A LEFT OUTER JOIN

DLSGATEWAY.LA4_CLASS_TOTALS B ON A.JURISDICTIONCODE = B.JUR_CODE

AND (B.FISCAL_YEAR = 2012)

ORDER BY A.JURISDICTIONCODE

Hello,

Just a quick question…

table A contains 351 records
table B contains 338 records

I’m doing a left outer join on table A but I’m only getting a return of 338 records when I would expect to see 351. Where there isn’t a record in table B, I would expect to see NULL in the b.jur_code field. What the hell am I doing wrong?

SELECT A.JURISDICTIONCODE, ****WHERE (A.JURISDICTIONCODE < 352) ****

I think you want a RIGHT outer join…not LEFT. Your code says to return all records in table B regardless of whether there is a match in table A.

Nope. That still returns 338 records. I nested the SELECT statements and got it to work. Roundabout and needless, but I can’t figure it out the other way. Weird.

Ah yes, I see it now.

Cheers!