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?

3
  • 1
    Fairly certain you are going to have to filter post-query with Apex.
    – Adrian Larson
    Commented May 19, 2015 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? Commented May 19, 2015 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. Commented May 19, 2015 at 20:38

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .