I am using a list in my soql, the list is formed with different names of countries from set of seperate records. The list(name - countryList) is of format.
List<ABC__c> rlList = ABC__c.getall().values();
Set<String> countryList = new Set<String>();
for (ABC__c pr : rlList){
String countrywithquotes = '\''+ pr.Country__c + '\'';
countryList.add(countrywithquotes);
}
countryList - {'India', 'USA','UK','China','Brazil'}
Query String in Apex Code -
String qry = 'Select Id, country__c from BDC__c where Country__c IN ('+ countryList +') '
In debug log , the SOQL query string produces a query like below -
Select Id, Country__c from ABC__c where Country__c IN ({'India', 'USA','UK','China','Brazil'})
Please let me know a way to remove the extra { character so that the SOQL can be executed.