I am using DBForge Query Builder
I have one table with a number of columns which contain abbreviations. Another table contains the descriptions for the abbreviations.
What is a query to replace the abbreviations with their descriptions?
I tried a number of joins without any success.
T1
ID Date Type Cat Sub Cat
1 01/09/18 E F L
2 05/09/18 Cc F D
3 06/09/18 Cc C Dr
4 08/09/18 Cc C Sh
5 08/09/18 E C Sh
T2
Code Des
E Eft Payment
Cc Credit Card
F Food
C Clothes
B Breakfast
L Lunch
D Dinner
Sh Shirt
Dr Dress
Desired Output
ID Date Type D Cat D Sub Cat D
1 01/09/18 Eft Payment Food Lunch
2 05/09/18 Credit Card Food Dinner
3 06/09/18 Credit Card Clothes Dress
4 08/09/18 Credit Card Clothes Shirt
5 08/09/18 Eft Payment Clothes Shirt
Try below using multiple join by T2 with different alias
select
a.ID, a.date,
b.Des as TypeD,
c.Des as CatD,
d.Des as SubCatD
from T1 a inner join T2 b on a.type=b.code
inner join T2 c on a.Cat=c.code
inner join T2 d in a.SubCat=d.code