Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to compare 1st 5 fields from 2 tables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
maxsubrat

New User


Joined: 27 Feb 2008
Posts: 87
Location: india

PostPosted: Fri Feb 15, 2013 5:10 pm    Post subject: How to compare 1st 5 fields from 2 tables
Reply with quote

Can someone correct me if i use to compare the 1st 5 fields between 2 tables... will the below condition work? when i run the below condition, then i am getting records which are equal to rather than not equal to.

SELECT * FROM TABLE 1 C
, TABLE 2 G
WHERE EMP1 = EMP2
AND ((C.ORIGIN,1,5) <> (G.ORIGIN,1,5)
OR (C.DEST,1,5) <> (G.DEST, 1,5) ) ;

Thanks in advance
Max
Back to top
View user's profile Send private message

Jerin Scaria

New User


Joined: 17 Feb 2013
Posts: 1
Location: USA

PostPosted: Sun Feb 17, 2013 3:01 am    Post subject: How to compare 1st 5 fields from 2 tables
Reply with quote

use SUBSTR function to get the first few chars of the column value.

and if you you are using two not equal to conditions, i think it should be connected with logical operator AND rather than OR.

SELECT * FROM TABLE 1 C
, TABLE 2 G
WHERE EMP1 = EMP2
AND (SUBSTR(C.ORIGIN,1,5) <> SUBSTR(G.ORIGIN,1,5)
AND SUBSTR(C.DEST,1,5) <> SUBSTR(G.DEST, 1,5) ) ;
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 0 Thu Dec 14, 2017 8:13 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am
No new posts Compare and COPY using DFSORT pshongal DFSORT/ICETOOL 3 Fri Nov 17, 2017 9:49 am
No new posts Selecting a row from multiple tables! Vignesh Sid DB2 2 Thu Oct 26, 2017 6:09 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us