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
minnuchcloud@gmail.comminnuchcloud@gmail.com 

How to write a Query

Custom object name is employ__C

And fields are city__c

Sex__c

Department no__C

Salary__C

I need a quarry for list of records ,if I enter into sex field 'male' I need  all male records,and same for  'female' records 

And if I enter department no I need all male and female and city and salary records 

If I enter into salary  I need all records city ,sex ,department no ,

 

 

 
  

Pl send me this query 

 

 

 

bob_buzzardbob_buzzard

How are you storing the user's selections?  I.e. are you capturing these into an instance of Employee__c that carries the criteria, or are they stored in string variables etc?

 

It sounds like you may need to use dynamic apex to build the query based on the user's selections.  There's an example of this in the following blog post (not mine):

 

http://blog.crmscience.com/2012/02/dynamic-soql-queries-with-zero-to-many.html

minnuchcloud@gmail.comminnuchcloud@gmail.com

capturing these into an instance of Employee__c

minnuchcloud@gmail.comminnuchcloud@gmail.com

Sir  I need client when ever  enter any field like ' city ' then he will get that city records including employees gender and department no and salary , 

I want salary range  >=10000

<=100000

And I f client didn't enter into city field then he will get all records of male and female

Like that I need sir Pl 

 

 

bob_buzzardbob_buzzard

Check the link I posted - that builds a query dynamically based on populated fields.