0

Hi,
I have two tables called header user, inbox. The table structures mentioned below,

User:

NUM_USER    VCH_NAME    VCH_PHONE_NO    VCH_STATUS
1           XXXX        123              Y
2           YYYY        321              Y
3           ZZZZ        456              Y

INBOX    

NUM_ID(P.K) NUM_CUST_ID    NUM_SEND_CALL_ID    NUM_REC_CAL_ID     DTT_DATE
1           10                  2                     1           4/11/2014
2           10                  3                     2           4/11/2014
3           10                  3                                 4/11/2014
4           10                  1                                 4/11/2014

* NUM_SEND_CALL_ID, NUM_REC_CAL_ID ARE FOREIGN  KEY REFERENCES USER TABLE

Now I want to map Inbox table, user table and get the result below mentioned form,

 ID  (Inbox)     Sendername(User table vch_name)    Receivedusername (user tablevch_name )
     1                    YYYY                                      XXXX
     2                    ZZZZ                                      YYYY
     3                    ZZZZ
     4                    XXXX   

Please give some suggestion to achieve my result. 
2
Contributors
1
Reply
17
Views
3 Years
Discussion Span
Last Post by vsmash
0
SELECT        NUM_ID, caller.VCH_NAME as Sendername, user.VCH_NAME AS Receivedusername
FROM            INBOX INNER JOIN
                         User AS caller ON INBOX.NUM_SEND_CALL_ID= caller.NUM_USER LEFT OUTER JOIN
                         USER ON INBOX.NUM_REC_CAL_ID = User.NUM_USER

Edited by vsmash: typo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.