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

How can we write this in SQL query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Fri Oct 13, 2006 11:30 am
Reply with quote

Can somebody help. I have to collect all the names who work under dept "XYZ". i mean i have to match the two id fields and then i have to check and for XYZ dept i have to collect all the names from first table.

TABLE_1
-------
ID1 NAME

TABLE_2
-------
ID2 DEPT
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Fri Oct 13, 2006 11:38 am
Reply with quote

Hi there,

SELECT TABLE_1.NAME
FROM TABLE_1, TABLE_2
WHERE TABLE_1.ID1=TABLE_2.ID2
AND TABLE_2.DEPT ='XYZ';

Hope it will useful
Back to top
View user's profile Send private message
prashanth1

New User


Joined: 27 Sep 2006
Posts: 47
Location: Hyderabad

PostPosted: Fri Oct 13, 2006 11:44 am
Reply with quote

SELECT A.EMP_NAME FROM TABLE_1 A, TABLE_2 B

WHERE A.ID1 IN (SLECT B.ID2 FROM TABLE_2 WHERE B.DEPT="XYZ");

Pls Correct Me, If I Wrng icon_smile.gif
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top