0

I have Database.query that sorts records by a few filters (or any filter). I want to set the limit for it. How should a write it?

return Database.query('SELECT Id, Name FROM Stereo_System__c' + 
                     (filters.isEmpty() ? '' : ' WHERE ' + String.join(filters,' AND ')));
  • 2
    Query = Query+' LIMIT 2000' will work. Are you facing any error? – Tushar Sharma Jan 30 at 12:02
1

Something like this should work

return Database.query('SELECT Id, Name FROM Stereo_System__c' + 
                     (filters.isEmpty() ? '' : ' WHERE ' + String.join(filters,' AND ')) + ' LIMIT 50000');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.