Reputation: 2174
I got stuck at one point. I have a table structure as
I Need result as
I tried to join, Union etc of tables,but I am not able to get it. Can you please help me.Thanks in advance.
Upvotes: 1
Views: 48
Reputation: 31879
Assuming your first table is Ring
and the second one is RingTone
You have to JOIN
to the Ring
table twice:
SELECT
rt.ID,
DayRingTone = r1.RingName,
NightRingTone = r2.RingName
FROM RingTone rt
INNER JOIN Ring r1
ON rt.DayRingTone = r1.RingID
INNER JOIN Ring r2
ON rt.NightRingTone = r2.RingID
Upvotes: 4
Reputation: 4844
Try this way
SELECT
rt.ID,
DayRingTone = b.RingName,
NightRingTone = c.RingName
FROM tableringtone a
INNER JOIN tablering b
ON a.DayRingTone = b.RingID
INNER JOIN tablering c
ON a.NightRingTone = c.RingID
Upvotes: 2