Skip to main content
2 of 4
deleted 11 characters in body; edited tags; edited title
Jamal
  • 34.9k
  • 13
  • 133
  • 237

SQL with several joins

Is this query acceptable in terms of performance (I get the correct data) or can it be optimized?

SELECT
    bankInstitution.name,
    person.firstName,
    person.surname,
    offer.offerId,
    bank.personId,
    bank.bankOtherName,
    bank.sortCode,
    bank.number,
    loan.loanId
    offer.campaignId,
FROM bank
    JOIN loan ON bank.personId = loan.personId AND bank.isCurrent = 1
    JOIN offer ON loan.loanId = offer.loanId
    JOIN person ON person.personId = bank.personId
    JOIN bankInstitution ON bankInstitution.bankInstitutionId = bank.bankInstitutionId
WHERE Campaign.Offer.CampaignId = :campaignId AND Campaign.Offer.Processed Is NULL
mitomed
  • 539
  • 1
  • 4
  • 16