I need the dynamic SOQL query with open braces and closed. But I am not getting that... need query like
select field1__c, field2__c from Object__c where field1__c = id AND (field2__c == 'abc' OR field2__c == 'jkl').
I tried like this my exact query below
string teamquery = 'select '+packageNamespace+'Response_Date__c,'+packageNamespace+'RBM_Template_Team__r.name,'+packageNamespace+'Participant_Name__c,'+packageNamespace+'Role__r.Name from '+packageNamespace+'RBM_Template_Team__c where '+packageNamespace+'RBM_Template__c = \'' + recid +'\'';
string temp = packageNamespace+'Role__r.Name = \''+'Project Manager'+'\'';
temp += ' OR '+ packageNamespace+'Role__r.Name = \''+'Statistician'+'\'';
temp += ' OR '+ packageNamespace+'Role__r.Name = \''+'Medical Monitor'+'\'';
teamquery += ' AND (\''+temp+'\')';
MyQuery = DataBase.query(teamquery);
but I am getting error unexpected token: 'CTMax__Role__r.Name = ' An unexpected error has occurred. Your development organization has been notified.
I got the solution, updated below line.. teamquery += ' AND ('+temp+')';
OR'+ packageNamespace+'field2__c