View previous topic :: View next topic
|
Author |
Message |
madmartinsonxx
New User
Joined: 10 Dec 2010 Posts: 96 Location: Massachusetts
|
|
|
|
Code: |
SELECT DISTINCT B.LEGACY_VEND_NR
FROM DAAVEND.VENDOR A,
DAAVEND.PAYEE B
WHERE B.LEGACY_VEND_NR = A.LEGACY_VEND_NR;
|
I am trying to get just one vendor number from 2 tables. If it exists in just one table I need that in the result set. If the vendor number appears in both tables I just need one in the result set.
I don't think the code above will do that. I think he will just pick the ones in the PAYEE table.
We run Version 9 Release 1.
There is another application I will need this process for and once I get this licked I can wrassle the next one down no problem. Thanks ! |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
Your query as written will return a value only if both tables contain the same vendor number.
An Outer Join should do the trick. Or a Union. |
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Hi Martin,
It sounds like you are just looking for that Vendor number and it doesn't matter in which table it is found. In that case, you can something like this,
Code: |
SELECT LEGACY_VEND_NR
FROM DAAVEND.VENDOR
Union
SELECT LEGACY_VEND_NR
FROM DAAVEND.PAYEE |
Thanks,
Sushanth |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
basic SQL : UNION
"Mainframe Skills: DB2, IDMS, SAP, Oracle " ? I don't think so |
|
Back to top |
|
|
|