🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #364

Re: Join - understand strange results

#364
From: Wayne Niddery (TeamB)
Date: Mon, 21 Apr 2008 14:51
39 lines
2409 bytes
"Adalberto Baldini" <finman@swissonline.ch> wrote in message 
news:480c85b4$1@newsgroups.borland.com...
>
> from giocoge a
> left join  ABFL_USRSOCINP_UNO (:UTENTE, a.csoc, a.nreserc, a.abinp, a.fil) 
> b
> on (1=1)

This is exactly the same as:
    select [...]
    from
      giocoge a,
      ABFL_USRSOCINP_UNO (:UTENTE, a.csoc, a.nreserc, a.abinp, a.fil) b

It is a cartesian join, meaning every row from b will be matched with every 
row from a. E.g. if there are 3 rows returned by both a and b, then this 
query will produce 9 rows.

> if I change join in :
>
> left join  ABFL_USRSOCINP_UNO (:UTENTE, a.csoc, a.nreserc, a.abinp, a.fil) 
> b on (a.abinp = b.abinp and a.fil = b.fil  )  ....
>
> I get  :
> ABIT   DETO    null    null    null    null
>
> Why I loose joined data in 2nd row?
> comparison is done on same data passed as parameters.

Because you are now requiring a match between fields. Apparently, for the 
above row, there is no matching record returned by the stored procedure (no 
match on abinp or fil fields). If you change "left" to "inner", this record 
will not show up at all. "Left" requires all records from a to be returned 
even if no match in b, but in that case, b's fields will be returned as 
null.

-- 
Wayne Niddery - TeamB (www.teamb.com)
Winwright, Inc. (www.winwright.ca) 
Technical Details
Message-ID: <480ca9f3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail
References: <480c85b4$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,11ad783c403646e4
X-Google-Attributes: gid114a0e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Wayne Niddery \(TeamB\)" <wniddery@chaffaci.on.ca>
Newsgroups: borland.public.interbase.sql
References: <480c85b4$1@newsgroups.borland.com>
In-Reply-To: <480c85b4$1@newsgroups.borland.com>
Subject: Re: Join - understand strange results
Date: Mon, 21 Apr 2008 10:51:13 -0400
Lines: 40
MIME-Version: 1.0
Content-Type: text/plain;
 format=flowed;
 charset="iso-8859-1";
 reply-type=response
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18000
NNTP-Posting-Host: 24.137.214.213
Message-ID: <480ca9f3$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1208789491 24.137.214.213 (21 Apr 2008 07:51:31 -0700)
X-Authenticated-User: wniddery
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail