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
SimrinSimrin 

Where clause for picklist

public List<CustomClass> list = [Select AColumn__c, BColumn__c
                                                  From CustomClass
                                                  WHERE UserId = :UserInfo.getUserId() 
                                                         and BColumn__c =:'TEST'];

Also tried
BColumn__c like 'TEST%'

BColumn__c is a Picklist which can have value TEST, TEST01, TEST03,etc


I am not able to make a correct string comparision

Best Answer chosen by Simrin
James LoghryJames Loghry
Try just 
Bcolumn__c = 'Test'

The colon is for variable binding, for example BColumn__c = :someStringVariable

If you need to make the query work with multi select picklists you can also use the INCLUDES function (See here for more info: http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_calls_soql_querying_multiselect_picklists.htm)

All Answers

James LoghryJames Loghry
Try just 
Bcolumn__c = 'Test'

The colon is for variable binding, for example BColumn__c = :someStringVariable

If you need to make the query work with multi select picklists you can also use the INCLUDES function (See here for more info: http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_calls_soql_querying_multiselect_picklists.htm)
This was selected as the best answer
Grazitti TeamGrazitti Team
Hi Simrin,

Just do a small change in your SOQL and you will get the result as you expected.

Modified SOQL:
public List<CustomClass> list = [Select AColumn__c, BColumn__c
                                                  From CustomClass
                                                  WHERE UserId = :UserInfo.getUserId() 
                                                         and BColumn__c =:TEST'];
I hope the above solution is useful for you.

Please Mark this as Best Answer if it helps you

Regards,
Grazitti Team
Web: www.grazitti.com
Email: sfdc@grazitti.com
 
CloudGoferCloudGofer
https://search.cloudgofer.com/#gsc.tab=0&gsc.q=Query%20Multi-Select%20Picklists&gsc.sort= (https://search.cloudgofer.com/#gsc.tab=0&gsc.q=Query%20Multi-Select%20Picklists&gsc.sort=)

; (semi colon) Specifies AND for two or more strings. Use ; for multi-select picklists when two or more items must be selected.
, (comma) specifies AND