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
rajuravularajuravula 

how to write a SOQL query where we don't know the value of "WHERE" condition..

Hiii.....how to write a SOQL query where we don't know the value of "WHERE" condition..

  Thank you

*rdinakaran**rdinakaran*

List<Account> Acc = new List<Account>();

Acc = [select id,Name from Account];

 

you can use the above

 

-rdinakaran

gitguygitguy

Check out Database.query().  You can compose the entire query as a string then submit the SOQL.

rajuravularajuravula

Thanks for reply...here my requirement is..

      through the trigger  i wanna update a field from retrieving it from picklist of another object....So i have written a query...

  "Then it will says List has more than one values to be assigned to a field"...then i wanna write a query for only one value of picklist....we can use WHERE  but we don't know the value of where condition...

  So,please give detalied solution for this...........

gitguygitguy

aField.getDescribe().getPicklistValues()

 

will give you a list of the possible picklist values.  You should be able to create your where clause from that using either string concatenation or String.Format().