+ 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