You need to sign in to do that
Don't have an account?
sfquestiondev
Limit in select
Hi, In MySQL we have limit on select for examle "SELECT * from Table where x=y order by z LIMIT 5,10"
It will return only 6,7,8,9 rows.
What is a equal sintax in appex trigger?
Unfortunatly there is not a similar syntax.
You would have to put the LIMIT 10 in a SIQL, results to a list, then access hte list using array notation [6] [7] [8] [9] etc
Hi,
Same syntax is not availabel in Apex..
You can do like this
There is no * fro query you need to put manuaaly all teh fields like below
List<ObjectAPIName> lstOBj=[select Id,Name from ObjectName limit 10];
//Now in lstOBj you have 10 records
//For 6th record
ObjectAPIName obj6thRecord=lstOBj[5];
//For 7th record
ObjectAPIName obj7thRecord=lstOBj[6];
//For 8th record
ObjectAPIName obj8thRecord=lstOBj[7];
//For 9th record
ObjectAPIName obj9thRecord=lstOBj[8];
//For 10th record
ObjectAPIName obj10thRecord=lstOBj[9];
//If you want all the record you can iterate in loop like below
for(ObjectApiName varObj:lstOBj){
sysytem.debug('varObj--------------->' + varObj);
}
Let me know if need any other help on this
Thanks
techie.in.sf@gmail.com
Hi,
Use can do something like this:
List<account> acn=new list<account>();
for(account ac:[select id from account limit 10])
{ Integer i=1;
i++;
If(i>5 !! i<10)
{
acn.add(ac);
}
}
System.debug(‘@@@@@@@@@@@’ +acn);
And for working like * u have to make an string which will contain all the fields related to that object and pass that string as query using database.query method.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.