0

I have a field which contains values like [1234] - Sample, [1234F] - Face Sample and further more. I want to get the rows using SOQL query with this field in where condition, when using below query there are no rows returned

Select Name, Id, Sample__c from Custom_Object__c where Sample__c = '[1234] - Sample'

Even checked in Developer Console under Query tab, it did not returned any rows. But with below query I got results (which included few unwanted rows too because of Like condition)

Select Name, Id, Sample__c from Custom_Object__c where Sample__c LIKE '%1234%'

But I want only rows which were matching with entire value rather than LIKE. Please suggest me how to achieve it.

Note sometimes values can be "[1234] & [1234F] - Sample case"

1 Answer 1

1

That query should work. However, please be aware that there may be multiple contiguous spaces in your string; make sure you're paying attention. For example, here's an example using an Account:

Query Name = [1234] - sample

As you can see, I had no problem querying the record. So, there might be an extra space somewhere, such as [1234] - Sample or [1234] - Sample. These extra spaces may not always appear in some cases, so try querying the record and checking it carefully using the Data Loader or Query Editor.

1
  • Thank you very much. You were right there is an extra space in the picklist value which is causing the issue. Replaced the values and it is working fine.
    – getty
    Commented Feb 24, 2022 at 16:48

You must log in to answer this question.

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