Limit is used to limit the records in soql query. If you have 300 records in ur contact object .if you query on contact object with the following query: Contact c=[select id,name form contact]; system.debug('---->'+c); The query will return all 300 records. if you put limit in query it will return only one record in the query ex:- Contact c=[select id,name form contact limit 1]; system.debug('---->'+c); If you have more than 50000 records to query use list.
Limit is used to limit the records in soql query. If you have 300 records in ur contact object .if you query on contact object with the following query: Contact c=[select id,name form contact]; system.debug('---->'+c); The query will return all 300 records. if you put limit in query it will return only one record in the query ex:- Contact c=[select id,name form contact limit 1]; system.debug('---->'+c); If you have more than 50000 records to query use list.
Hi risha,
Limit is used to limit the records in soql query.
If you have 300 records in ur contact object .if you query on contact object with the following query:
Contact c=[select id,name form contact];
system.debug('---->'+c);
The query will return all 300 records.
if you put limit in query it will return only one record in the query
ex:-
Contact c=[select id,name form contact limit 1];
system.debug('---->'+c);
If you have more than 50000 records to query use list.
All Answers
Hi risha,
Limit is used to limit the records in soql query.
If you have 300 records in ur contact object .if you query on contact object with the following query:
Contact c=[select id,name form contact];
system.debug('---->'+c);
The query will return all 300 records.
if you put limit in query it will return only one record in the query
ex:-
Contact c=[select id,name form contact limit 1];
system.debug('---->'+c);
If you have more than 50000 records to query use list.
Hi risha,
You are using Limit 1 in your code to limit the records returned by your SOQL query to maximum 1 record.
You can change this limit according to your need and can limit to Max 50000 i.e. Limit 50000 in your SOQL to retrieve maximum 50000 records.
Ex :-
List<Account> accLst = [Select id,Name from Account Limit 100] ;
the above query will return Max 100 records.
If this post helps you then hit kudus by clicking on star and accept my post as a solution to your question.
thanks a lot for helped me now i understood clearly