I have a dynamic soql as below.
string remainingbetquery ='select id,name,uw_Brand__r.Name,Market_Cluster__c,Product_Category_Sub_Division__c from uw_bet__c where (id not in :betfollowed) and (id not in :betowners) ';
query = query + 'and BET__r.Product_Category_Sub_Division__c ='+'\''+categories+'\'';
for some reason its not properly working and returning correct values .
categories is a dynamic picklist generated by code as well.so when user selects a value in front end it gets populated in controller
Updated with controller code for categories
public List<String> categories {
get {
if (categories == null) {
categories = new List<String>();
Schema.DescribeFieldResult field = uw_bet__C.Product_Category_Sub_Division__c .getDescribe();
for (Schema.PicklistEntry f : field.getPicklistValues())
categories.add(f.getLabel());
}
return categories;
}
set;
}
Pagecode for picklist
Category <select id="categories" >
<option value=""></option>
<apex:repeat value="{!categories}" var="tech">
<option value="{!tech}">{!tech}</option>
</apex:repeat>
</select>