+ Start a Discussion
Iqra TechIqra Tech 

How to search two values in single search using dymaic query

I need to search two values 
like xyz1,xyz2 using single search on vf page also from dynamic query

currently i am having this query:-
string queryStr1 = 'SELECT ID, NAME, createdBy.Name, createdDate, lastModifiedBy.Name, lastModifiedDate,'+fldAPINameMap.get(selectedField)+' FROM '+selectedObject+' WHERE '+fldAPINameMap.get(selectedField)+' like \'%'+criteria+'%\'';
like i am selected Edition field on vf page now i am searching in search box :- Adipac 2018 this will running suceffuly but when i trying to search two values like :- Adipec 2018,Adipec 2017 so on this it is not working

can any one help me to achive this
Best Answer chosen by Iqra Tech
Raj VakatiRaj Vakati
If you want to search more than one values instead of like use the IN in conditions 

As per your need like will do either Adipec 2018 or Adipec 2017 based on what you are passing .. 

 
List<String> criteria = new List<String>() ;
criteria.add('Adipec 2018 ');
criteria.add('Adipec 2017');


string queryStr1 = 'SELECT ID, NAME, createdBy.Name, createdDate, lastModifiedBy.Name, lastModifiedDate,'+fldAPINameMap.get(selectedField)+' FROM '+selectedObject+' WHERE '+fldAPINameMap.get(selectedField)+' IN '+criteria+'';