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

Join in SQL Query


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

New User


Joined: 10 Jun 2015
Posts: 51
Location: India

PostPosted: Tue Jan 17, 2017 12:15 am
Reply with quote

Hi All,

Table1 contains details of employee which i want to fetch based on comman key Sap id in table2.

I have written below query to fetch the details of a employee and its reporting maneger(RM)

Code:
Select
  A.Name
 ,A.Lastname
 ,A.Empid
 ,A.Telephone'
 ,B.Designation
 ,A.RM
 ,D.Name
 ,D.Lastname
 ,D.Empid
 ,D.Telephone
 ,D.RM
from Table1 A
    ,Table2 B
Left Join Table1 D
    on D.Empid = A.RM
Where
     A.Empid = '219057'
And  B.Sapid = A.Sapid


But i am facing problem to fetch designation of RM(Reporting manager) in above query as its present in table2. Please help me with this.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Jan 17, 2017 11:37 am
Reply with quote

Provide Sample data and expected output. Describe your requirement clearly and also what is the exact problem you are facing.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Jan 17, 2017 11:20 pm
Reply with quote

You already getting what you want unless you stated incorrectly.
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 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
No new posts Query on edit primary command CLIST & REXX 1
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top