4

Is there anyway to perform a case sensitive SOQL Query? I have a field name "Policy Number" and I need to say something like:

SELECT Id, Policy Number FROM Case WHERE Policy Number LIKE 'abc%'

But the where statement needs to be case sensitive and look specifically for lowercase...

Thoughts?

  • 1
    Fairly certain you are going to have to filter post-query with Apex. – Adrian Larson May 19 '15 at 20:28
  • @AdrianLarson I think it is safe to say that the string Comparison Operators are case-insensitive and the case checking will need to be done over the initial results. Same for SOSL. Do you want to add an answer as such? – Daniel Ballinger May 19 '15 at 20:35
  • One crazy option would be to create a custom or formula field where only the lower case characters appear and then filter on that. Would probably be easier to stick with the post processing unless you envisage lots of query operations and many false matches. – Daniel Ballinger May 19 '15 at 20:38
3

The LIKE operator performs a case-insensitive match, unlike the case-sensitive matching in SQL. So if you want to get results according to the case sensitivity then you first have to fetch the records with LIKE operator in list and than addition check over the list to get case sensitive records.

Here is more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.