IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Query to fetch Exact Rows that satisfies the below cond.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts To get the count of rows for every 1 ... DB2 3
No new posts RC query -Time column CA Products 3
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top