View Single Post

   
  #2 (permalink)  
Old 02-29-2008, 07:30 AM
Brian
 
Posts: n/a
Default Re: Speed cost for using "or" clause and functions on join statement

Why are you using an OR clause within a JOIN clause? This is very
unorthodox. Simply continue joining namelist to members like this, where
"nl" is alias for namelist and "m" is alias for members:

join m on nl.ssn = m.id
join m on nl.custid = m.custid

OR clauses are notorious for slowing down a query - they only belong in the
WHERE clause, and even then you shoudl try to avoid them if possible



"Phillip" <pputzback@ECommunity.com> wrote in message
news:1110226815.864858.191770@o13g2000cwo.googlegr oups.com...
> Select member
> from NameList
> Inner join Members
> on (Left(Namelist.NameID,5) = Members.ID
> OR (left(namelist.SSN,9) = Members.ssn
> OR (Left(namelist.CustID,9) + '*01' = Members.CustID)
> where
> namelist.name <> ''
>
> How do I speed up a process like this? Can I create indexes on the
> members table based on a function
> Like an index based on the left(members.id,5)
>
> or should these statements go into the where clause?
>



Reply With Quote