Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Joins again
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Joins again
Divers
Thread ID:
00405995
Message ID:
00405995
Vues:
63
I'm having trouble finding documentation on how to do joins with many tables with varying relationships involved. In the following sql statement how does the interpreter know what is being joined with what, simply by the on phrases?

select m.lnkey, isnull(rtrim(b.borr_last),'')+', '+isnull(rtrim(b.borr_first),'')+' '+isnull(b.borr_middle,'') as borrname,
m.loanamt, m.prog, m.intrate, r.name as brokername, a.agentname, p.prop_state, g.location, g.property, g.occupancy, g.income
from empower.mtgterms as m
join empower.propinfo as p on m.lnkey=p.lnkey
join empower.gradeprice as g on m.lnkey=g.lnkey
join empower.borrinfo as b on m.lnkey=b.lnkey
join empower.brokeragents as a on m.agentid=a.id
join empower.brokerages as r on a.brokeracct=r.id
join empower.lendinfo as l on m.lenderid=l.id
where l.id='1' and b.whichborr=1

or does the ordering of the joins also play into this?

This statement seems to work in that I basically need inner joins for this report, but is it the best way to achieve such a thing?

TIA
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform