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
arasuarasu 

Does SOQL support "NOT LIKE" operator?

Hi,
I want to write a query like this:

select Account__r.Id,Account__r.Name,Account__r.Account_Country__c from Card_UPC__c where Account__r.partner_relationship_status__c='Allow Relationships To Be Created' and Account__r.Name not like 'Test%'.
 
The above query throws SOQL exception.
 
It works and runs when I remove the NOT operator as shown below:

select Account__r.Id,Account__r.Name,Account__r.Account_Country__c from Card_UPC__c where Account__r.partner_relationship_status__c='Allow Relationships To Be Created' and Account__r.Name like 'Test%'
 
My questions is: Does SOQL support "NOT LIKE" operator. If no, then what is the alternative to achieve a similar operation.
 
Thanks for all your feedbacks.
Ambili
Best Answer chosen by Admin (Salesforce Developers) 
arasuarasu

Hi Simon,

Thanks for your response. Actually the brackets were missing. The following SOQL works fine:

select Account__r.Id,Account__r.Name,Account__r.Account_Country__c from Card_UPC__c where Account__r.partner_relationship_status__c='Allow Relationships To Be Created' and  (NOT Account__r.Name  like 'Test%').

Thanks,
Ambili

 

All Answers

SuperfellSuperfell
http://www.salesforce.com/us/developer/docs/api/index_CSH.htm#sforce_api_calls_soql_select.htm#comparison_operators

not foo__c like 'bar%'
arasuarasu

Hi Simon,

Thanks for your response. Actually the brackets were missing. The following SOQL works fine:

select Account__r.Id,Account__r.Name,Account__r.Account_Country__c from Card_UPC__c where Account__r.partner_relationship_status__c='Allow Relationships To Be Created' and  (NOT Account__r.Name  like 'Test%').

Thanks,
Ambili

 

This was selected as the best answer
hemantgarghemantgarg

I found it very useful, Thanks!

sfdcdev.wordpress.comsfdcdev.wordpress.com
Correct answer at - http://sfdcdev.wordpress.com/2013/12/26/not-like-soql-salesforce-com/
Robert JoyRobert Joy
Thank you!
Watson CarrenWatson Carren
Watson CarrenWatson Carren
Edit Video Like a Pro With KineMater (https://apkright.com/kinemaster-mod-apk/)
howar dellishowar dellis
A great answer!
Refer to io games (https://iogames.onl) list games new 2022
Hieu Pham 9Hieu Pham 9
A perfect answer for users. I'm also applying it to wordle game (https://wordlenew.com/)
hanh tran 10hanh tran 10
Thanks for the great and helpful post (<a href="
https://fnafunblock.com/
" target="_blank" rel="nofollow" id="ext-gen47">
https://fnafunblock.com/
</a> ).
hanh tran 10hanh tran 10
Cảm ơn vì bài viết tuyệt vời và hữu ích(five nights at freddy's)
agario bostonagario boston
A great answer!
Refer to io games (https://agario.boston) New Game I can recommend.
Cosmic DreamerCosmic Dreamer
I learned something new from this article. Thank you!
Best Regards
Savevideo.red (https://savevideo.red/en)
Peyton SawyerPeyton Sawyer
Indeed something new to learn.
I am gonna pass this to my team to use it accordingly for our project of porcsi - TPMS Supplier (https://porcsi.com/).