I require to grab all account names which does not contain any number and display in the report. I am trying to query it using LIKE, but it is not working.

My query - [select name from account where NOT name like ('%1%','%2%')]

Error -

Unknown Error parsing Query

Here I am planning to add numbers from 0 to 9 so that it will return me only account names with characters, not number.

Plz help me out if one knows how to do it.


This syntax is not supported in regular SOQL, but there's still way to do this in Apex code. We are allowed to bind like to a collection:

String[] filters = new String[0];
for(Integer i = 0; i <= 9; i++) {
Account[] records = [select name from account where not name like :filters];

This would find all accounts that meet your criteria, although it will fail if you have too many records, since this would be a non-selective query.

| improve this answer | |

Create a boolean formula field and perform all those checking about not having numbers and finally use that field in SOQL filter condition.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.