> Reeve wrote:
> I'm stumped: what's the SQL syntax for joining two files on multiple
columns
> (joining both "city" and "state")?  I can do in Oracle SQL but not in
> OS/400, and there doesn't appear to be a single example of doing this in
any
> IBM manual.
>
> Thanks,
> Reeve

Reeve,

Here is another way (using left outer join):

select *From
sjl001/cusmst aa
left outer join sjl002/cusmst bb
on  aa.cunbr = bb.cunbr
and aa.culnam = bb.culnam

and another (using inner join):

select *From
sjl001/cusmst aa
inner join sjl002/cusmst bb
on  aa.cunbr = bb.cunbr
and aa.culnam = bb.culnam

and another (using a correlated join):

select *From
sjl001/cusmst aa  where exists
(select *  from sjl002/cusmst bb
where  aa.cunbr = bb.cunbr
and    aa.culnam = bb.culnam)

and here's an exception join -
(unmatched records - shows records in SJL002/CUSMST
 that *don't* exist in SJL001/CUSMST, based on joining the
 two fields CUNBR and CULNAM):

select *From
sjl002/cusmst aa
exception join sjl001/cusmst bb
on  aa.cunbr = bb.cunbr
and aa.culnam = bb.culnam

Finally -
Try looking here for more information (in the info center,
under Database and file systems>DB2 UDB for iSeries>Examples):

http://publib.boulder.ibm.com/iseries/v5r1/ic2924/info/rzahf/rzahfex0.htm

Scroll down until you see the section on Joins...

Hope this helps,

Steve Landess
Austin, Texas
(512) 423-0935

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.