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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Conditional highlighting of rows in I... packerm CLIST & REXX 2 Thu Sep 21, 2017 6:50 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm

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