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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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