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 All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DB2 Query to get the count of Unique ... DB2 2
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 1
No new posts Reflection 3270 screen shows only 23 ... Compuware & Other Tools 6
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 5
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
Search our Forums:


Back to Top