-2
    List<String> cityList = Label.cityNames.split(',');
    String SOQL = 'Select id, name from Account where city IN:cityList'

    Databse.executeQuery(SOQL);

Could you please correct the above query to bind the list into SOQL.

The above dynamic SOQL is working fine if I pass new List<String> {'A','B','C'}

4

1 Answer 1

1

There is no standard field name called "City", it should be BillingCity or ShippingCity. Check with below query and use Database.Query instead Database.ExecuteQuery

List<String> cityList = Label.cityNames.split(',');
system.debug('--- cityList ---'+cityList);
String strQuery = 'Select id, name from Account where Billingcity IN:cityList';
List<Account> lstAccount = Database.query(strQuery);
system.debug('--- lstAccount ---'+lstAccount);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .