+ Start a Discussion
Nitin ghaiNitin ghai 

Soql Data Type

I want to know is it possible to use where clause in SOQL query on the data type. Example if I have A custom object and within that, I have 4 checkbox fields. and I want to query only those checkboxes which are true. And moreover, can we get field label from SOQL query.

So is it possible through SOQL query?
Sandra WicketSandra Wicket
Hi Nitin, 
in each soql statement you have to call the api object name and the api field name. So in your case [ Select Id, ...... FROM Object WHERE 
checkbox1 == true AND checkbox2 ==true AND....   
Nitin ghaiNitin ghai
Hi Sandra,

No, it's not working I am still getting all 4 checkboxes even if they are not true. And I don't think AND Condition will work here because if only Checbox1 is only true and rest 3 are false then, in that case, it won't fetch Checkbox1 because in our condition we have used AND. Correct me if I am wrong.
v varaprasadv varaprasad
Hi Nitin,

No, As Sandra mentioned it will work .

Change query like below 
Select Id, ...... FROM Object WHERE 
checkbox1 = true AND checkbox2 =true AND....

Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

@For Support: varaprasad4sfdc@gmail.com
Sandra WicketSandra Wicket
yes, because the query checks each row. You are looking for values and not datatypes. You have to define your case in the statement.  If you want all record with at least one checkbox == true, you have to use OR ..

Perhabs i dont unterstand your need correctly