SQL Combining two joins -
i understanding of sql average, wondering if there way more efficiently write statement?
the primary key of table company uniqentity , has company name nameof in row.
in table line, primary key uniqline , have columns entitycompanybilling , entitycompanyissuing (both foreign keys uniqentity).
this code below works fine, trying make more efficient. possible?
select l.uniqline, b.nameof billingcompany, l.uniqentitycompanybilling, i.nameof issuingcompany, l.uniqentitycompanyissuing line l inner join company b on b.uniqentity = l.uniqentitycompanybilling inner join company on i.uniqentity = l.uniqentitycompanyissuing
changing structure of query may not make more efficient (it seems simple can be). changing structure of data might:
- add indexes (if not already) on
uniqentitycompanybilling,uniqentitycompanyissuing add index ondidn't catch column pkcompany.uniqentity- if index on
company.uniqentityisn't clustered, includenameoffield in index oncompany.uniqentityquery doesn't have go physical table.
Comments
Post a Comment