+ Start a Discussion
rrichardrrichard 

SOQL equivalent for NOT LIKE...

Trying to do the following but not having much luck... is there a way to do this?

 

SELECT Id, Name FROM Account WHERE BillingCity NOT LIKE '%Bentonville%'

 

Thanks.

Ritesh AswaneyRitesh Aswaney

How about

 

SELECT Id, Name FROM Account WHERE Id NOT IN (Select AccountId from Contact where Account.BillingCity LIKE '%Bentonville%')

 

In case you're wondering about the second soql query being on Contact, its because the SOQL Editor complains about how the inner and outer queries cannot be on the same object

SuperfellSuperfell

SELECT Id, Name FROM Account WHERE NOT (BillingCity LIKE '%Bentonville%')

rrichardrrichard

Thanks for the quick response... much appreciated!

sfdcdev.wordpress.comsfdcdev.wordpress.com
Correct solution at - http://sfdcdev.wordpress.com/2013/12/26/not-like-soql-salesforce-com/
David Bruce 44David Bruce 44
NOT should go within the parentheses. You will get an error if you have an AND clause