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 on company.uniqentity didn't catch column pk
  • if index on company.uniqentity isn't clustered, include nameof field in index on company.uniqentity query doesn't have go physical table.

Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -