2
LEFT JOIN schools ON (bt.MidSchool LIKE schools.Name OR **%schools.Name% LIKE bt.ElmSchool**) WHERE ...

This is the portion of my SELECT that I have problems with.

I would like to find if the string in column schools.Name exist in column bt.ElmSchool

When I add % before and after the column name %schools.Name% I get a syntax error. if I use '%schools.Name%' the query is perform but it's looking for the column name instead of its value. I have tried escaping but didnt work. any idea??

1 Answer 1

5
  ...
  LEFT JOIN schools ON bt.MidSchool LIKE schools.Name 
                       OR bt.ElmSchool LIKE '%' + schools.Name + '%'
WHERE
  ...
1
  • Thanks Michael, i've tried it but it doesn't work....i don't get the value in column schools.Name....i get OR '%' + sc.Name + '%' LIKE bt.ElmSchool in my query which doesnt yield the needed result...
    – O B
    Commented Jan 27, 2012 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.