function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shillshill 

Query support for "Not Like" operator

Hello,
 
I know that I can have a query in the API that searches for wild card matches:
 
Select AnnualRevenue, City, Company, Country, Email, HasOptedOutOfEmail, Fax, FirstName, Name, Id, LeadSource, MobilePhone, Phone, Rating, Salutation, State, Status, Street, Title, Website, PostalCode, Owner.Name From Lead where LastModifiedDate>=2008-03-04T22:24:39Z AND Email like  'a%'
 
Is there any support for a "Not Like" operator?  Something like the following:
 
Select AnnualRevenue, City, Company, Country, Email, HasOptedOutOfEmail, Fax, FirstName, Name, Id, LeadSource, MobilePhone, Phone, Rating, Salutation, State, Status, Street, Title, Website, PostalCode, Owner.Name From Lead where LastModifiedDate>=2008-03-04T22:24:39Z AND Email not like  'a%'
 
I know this specicif example doesn't work in the API, but I was wondering if there was a way to do something like this.
 
Thank you,
Scott
SuperfellSuperfell
where lastActivityDate > 2008-03-08 and not (email like 'f%')

All the operators are detailed in the section on SOQL in the API docs.
shillshill
Hi Simon,
 
I am still having trouble with this one.  Here is my query:
 
Select AnnualRevenue,City,Company,Country,Email,HasOptedOutOfEmail,Fax,FirstName,Name,Id,LeadSource,MobilePhone,Phone,Rating,Salutation,State,Status,Street,Title,Website,PostalCode,Owner.Name From Lead where LastActivityDate>=2008-03-04 AND Not (Email like  'a%')
 
Here is the error I am getting back:
MALFORMED_QUERY:  LastActivityDate>=2008-03-04 AND Not (Email like  'a%')                                   ^ ERROR at Row:1:Column:242 unexpected token: Not
 
Any suggestions?
 
Thank you,
Scott
shillshill
I think I have it.  It looks like the "NOT" operator needs to be inside the brackets:
 
Select AnnualRevenue,City,Company,Country,Email,HasOptedOutOfEmail,Fax,FirstName,Name,Id,LeadSource,MobilePhone,Phone,Rating,Salutation,State,Status,Street,Title,Website,PostalCode,Owner.Name From Lead where (LastActivityDate>=2008-03-04) AND (Not Email like  'a%')
 
Thank you for all of your help!
 
Scott