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
Michael Webb 15Michael Webb 15 

Can't get the SOQL correct Limit 100

I am not sure what I am doing incorrectlly, I am pretty new.

Here is my query, I need to add a limit in there no matter what I try it is not working.

public PageReference submitCase() {
         List<Account> accts = [SELECT Id FROM Account WHERE AccountNumber = :acctNum];

I tried which I thought would work.

List<Account> accts = [SELECT Id FROM Account [Limit 100] WHERE AccountNumber = :acctNum limit 10];

But it is not.  Thanks in advance!
Keshab AcharyaKeshab Acharya
Here is how you can do it. mark as answer if it really helps you.
 
List<Account> accts = [SELECT Id FROM Account WHERE AccountNumber = :acctNum limit 10];

 
Amit Chaudhary 8Amit Chaudhary 8
Please try below Query i hope that will help you.
List<Account> accts = [SELECT Id FROM Account WHERE AccountNumber = :acctNum limit 100] ;
Please check below post for limit.
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_limit.htm

LIMIT is an optional clause that can be added to a SELECT statement of a SOQL query to specify the maximum number of rows to return.The syntax for LIMIT is
SELECT fieldList
FROM objectType
[WHERE conditionExpression] 
  [LIMIT numberOfRows]
Please let us know if this will help you