+ Start a Discussion

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%'



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


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


Thanks for the quick response... much appreciated!

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