× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks guys... I was just looking for the general idea of what to do. I
think I may have it now. I just have to test it. :'-(

-----Original Message-----
From: McManus, Duncan [mailto:Duncan.McManus@natexismetals.com]
Sent: Tuesday, December 18, 2001 8:49 AM
To: 'rpg400-l@midrange.com'
Subject: RE: SQL joining question



I don't know if there is anything simpler than this, but you could try:

SELECT a.custno, a.inv, ammoundue, ammount paid
FROM file1 a JOIN file2 b
ON a.custno=b.custno AND a.inv=b.inv
UNION
SELECT a.custno, a.inv, ammoundue, 0
FROM file1 a EXCEPTION JOIN file2 b
ON a.custno=b.custno AND a.inv=b.inv
UNION
SELECT b.custno, b.inv, 0, ammount paid
FROM file2 b JOIN file1 a
ON a.custno=b.custno AND a.inv=b.inv
ORDER BY 1,2

This should do:
1) select all rows in both
2) select all rows in file1 without any in file 2
3) all rows in file2 without any in file1

Hope that this helps


-----Original Message-----
From: Wills, Mike N. (TC) [mailto:MNWills@taylorcorp.com]
Sent: 18 December 2001 14:29
To: 'rpg400-l@midrange.com'
Subject: SQL joining question


I need to be able to select records from 2 identical files that have a
1-to-1 relationship. However, there are some records in file1 that isn't in
file2 and vise-versa... and I want the entire set. I need to do this as a
dynamic SQL statement in a RPG program. As an example:

file1
custno  inv     amountdue
1111            123             200
5555            120             200


file2
custno  inv     amountpaid
1111            123             050
6666            125           500

the result cursor would be:
custno  inv     amountdue       amountpaid
1111            123             200              050
5555            120             200              000
6666            125             000              500

What kind of join can be done for this? I have been unsuccessful so far in
figuring it out.

Any help would be appreciated.

Mike
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


================================================================
The integrity of this message cannot be guaranteed on the Internet.
Natexis Metals Limited cannot therefore be considered responsible
for the contents. Any unauthorised use or dissemination is prohibited.
If you are not the intended recipient of this message please delete it
and notify the sender.
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.