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
 
Query to fetch Exact Rows that satisfies the below cond.

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

New User


Joined: 23 Nov 2006
Posts: 22
Location: India

PostPosted: Tue May 15, 2007 3:23 pm    Post subject: Query to fetch Exact Rows that satisfies the below cond.
Reply with quote

Hi all
I have two tables as follows, I need to write a query to fetch all the ID from the Table-1 whose ID-name not equal to M12 and also should not include IDs whose Id-name has M12.(Here if we take ID 12 it has N12,M12,L12,K12 as ID-names. Since it has M12 it should not populate the ID 12.)

Table-1
ID(PK) ID-name(PK)
12 N12
12 M12
12 L12
12 K12
13 N12
16 M12
14 N14
15 M12


Table-2
ID(PK)
12
13
14
15
16
17
18
19


The Output should be from Table -1
ID ID-name
13 N12
14 N14

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

pyar
Warnings : 1

New User


Joined: 15 May 2006
Posts: 4

PostPosted: Wed May 16, 2007 9:05 pm    Post subject: Re: Query to fetch Exact Rows that satisfies the below cond
Reply with quote

SELECT ID-NAME, ID-NO FROM TABLE-1 WHERE ID-NO NOT IN (SELECT ID FROM TABLE-1 WHERE ID-NAME=?M12?)

Thanks
Pyar
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 reg query on DYNALLOC feature raghuraman123 SYNCSORT 12 Wed Jan 10, 2018 2:42 pm
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 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 Can we combine the rows with same key... V S Amarendra Reddy DB2 12 Fri Dec 01, 2017 10:29 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm

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