Reputation: 17
I have 2 tables 1 is Lookup and another is Details.
Lookup Table
Identity Type Value
200 Entity A
201 Entity B
202 Entity C
203 Entity D
300 SOURCE X
301 SOURCE y
Details Table
Sender(int) Reciever(int) Source(int) State(varchar)
200 203 300 hongkong
In the Details table Sender, Reciever are the Entity in Lookup table with Identity as their ids.
My problem is that when I write the query as Select Sender,Reciever,Source,State from Details
I am getting 200,203,300,hongkong
but I want the result as A,D,X,hongkong
.
Please help.
Upvotes: 0
Views: 71
Reputation: 1852
SELECT tSen.[Value] as [Sender], tRec.[Value] as [Reciever]
, tSou.[Value] as [Source], D.[State]
FROM Details as D
JOIN Lookup as tSen ON D.Sender = tSen.Identity
JOIN Lookup as tRec ON D.Reciever = tRec.Identity
JOIN Lookup as tSou ON D.Source = tSou.Identity
Upvotes: 1