Display field from another table in SQL
Posted
by Roland Bengtsson
on Stack Overflow
See other posts from Stack Overflow
or by Roland Bengtsson
Published on 2010-03-16T15:36:18Z
Indexed on
2010/03/16
15:41 UTC
Read the original article
Hit count: 287
I'm a newbie with SQL... Now I want to do display some instances of AddrDistances from DevExpress CxGrid with SQL.
Select Cast((DistanceAsMeters * 0.001) as Decimal(8,1)) DistanceAsKm, bold_id, created, fromAddress, toAddress
From AddrDistance
Where DistanceAsMeters = 0 and PseudoDistanceAsCostKm = 0
and not AddrDistance.bold_id in (select bold_id from DistanceQueryTask)
Order By Created Desc
This SQL is working and the result is:
DistanceAsKM Bold_ID Created FromAddress ToAddress
0 134808 16.02.2010 121795 134570
0 121701 10.03.2010 120850 122991
The result I want is this:
DistanceAsKM Bold_ID Created FromAddress ToAddress
0 134808 16.02.2010 Kalmar Stockholm
0 121701 10.03.2010 Falkenberg Oslo
So the amount of rows is right but I want to replace the numbers in FromAddress and ToAddress with strings from another table. The numbers shows here is just the boldid. Every object in the database have an unique boldid. The addresses above is stored in table Address and it have a City field with the column and a boldid as a key.
What should I write in SQL to get this right ? Is there something in the CxGrid that could help here ?
Regards
© Stack Overflow or respective owner