Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running the following query:

SELECT Name, ManagerID FROM User

The result yields a User's name and their corresponding Manager's user ID.

How can I return the Manager's name instead of the ID in SOQL?

share|improve this question
is your ManagerID field is a custom field of the User object itself? – highfive May 14 '14 at 18:24
up vote 5 down vote accepted

A great way to learn SOQL is to use the Schema Browser in the Eclipse IDE. In the screen shots below, I browsed to the User object:

enter image description here

Then scrolled down to the ManagerId field (note it is of type reference), then clicked on Type Data > Reference To > User > Fullname

enter image description here

And, SFDC has automatically built the SOQL for you in the Query pane:

enter image description here

Note: The 'u' can be omitted from your SOQL

share|improve this answer
Very handy! I guess that SF uses "references" rather than JOINs. I am more used to the SQL syntax and didn't know how such relationships would translate to SF without a JOIN. – toolshed May 15 '14 at 15:04
Apparently when you run this query the entire Manager user object is returned, not just the name. I would have thought that the dot syntax would remedy this, but it didn't. I tried to run the code in both the IDE and Developer console with the same difficulty. Is there any way to get around this? – toolshed May 16 '14 at 12:21

Did you try this:

SELECT Name, ManagerID, Manager.Name FROM User

Manager is lookup to User

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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