+ Start a Discussion
James MartucciJames Martucci 

Query For Users

Hello, I need some help.  I have 2000 account records.  Each account has an owner.  I want to display the manager of the owner on the account record.  For each account, I do a query tot the User object to retrieve the mangerId field.  Works for a few account records, but governor limits are reached for lots of account records.  Basically, for each account record, do a query to get the manager.  If 2000 accounts, then there are 2000 querys.  Way too many.  Can you help me architect a better solution?  Thanks.
StephaneTStephaneT
Just write a more specific query with a better criteria
Anil SavaliyaAnil Savaliya

Hi James,

You suppose to be write related Query like 

select   Owner.Manager.Id  from account  
sam sammsam samm
Add some limits to the query