+ Start a Discussion

I am getting "Expecting right square bracket, found 'OR'" error

I am trying to see why this error is occuring for my query. Help would be greatly appreciated.

 List<ContentVersion> cv = [Select Title, portal_effective_date__c, Portal_Effective_Until_Date__c,description, filetype, createddate, isLatest, id, brand__c, state__c, region__c, 
                                           dealer__c from contentversion where ContentDocumentId in (SELECT ContentDocumentId FROM ContentWorkspaceDoc WHERE ContentWorkspaceId = :workspaceId) 
                                           and (Brand__C ='' and region__C = '' and state__c ='') OR region__C = :selRegion OR state__c = :acc.Physical_State__c OR 
                                           (region__C = :selRegion and state__c = :acc.Physical_State__c) and isLatest = true order by Title ASC];
nitin sharma 190nitin sharma 190
Aren't u missing parentheses around  (region__C = :selRegion OR state__c = :acc.Physical_State__c ).You have parenthese around other or statements but not around the or mentioned above.

 Becasue it is supposed to act as.... and (Brand__C ='' and region__C = '' and state__c ='') OR (region__C = :selRegion) OR (state__c = :acc.Physical_State__c) OR 
                                           (region__C = :selRegion and state__c = :acc.Physical_State__c)