#Jet wrote:
FormInstances INNER JOIN FormInstanceData ON FormInstances.Id = FormInstanceData.FormInstanceId INNER JOIN Communities INNER JOIN Localities
Looks like error is here... Query is not properly formed. You have multiple INNER JOINS back to back without the join condition.
Furhter, how do you know the the invalid column error is in WHERE clause. For debug purpose (to catch the error line) Would suggest you to use print each line set by you for forming query. Use the print outputs, concatenate it and check where exactly it shows you wrong (if you can get through naked eyes well enough!)