Salesforce SOQL’s weird syntax for NOT LIKE queries

I just encountered the first SOQL syntax error I’ve had to look up in a long time.  Do you know how to write a NOT LIKE condition in a query?

I’m debugging an issue, and wanted to view a user report in our Salesforce environment.  The query was straightforward enough and I was baffled why I couldn’t get it to work.  I ran:

But was greeted with the message “ Unknown error parsing query.”

I can usually see SOQL syntax issues right away and fix it up but this one I had to Google.  The proper syntax is:

Note the necessary brackets, and the syntax: “NOT column_name LIKE value”.

At lunch I asked a colleague and he didn’t know this syntax either – which makes me curious why we haven’t needed to write more NOT LIKE queries than just this one.

Author: Matt

Matthew is a highly accomplished and award-winning programmer who is well versed in a variety of the hottest technologies powering today's most successful companies. With 11+ years of experience, Matthew has done it all: from the most rudimentary tasks to complex implementations of entire applications, CRMs, and pieces thereof. Today he spends his time mastering administration, development, and implementation as he mediates between stakeholders and project owners to successfully interface a complex company in a complex industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.