I think what I'm trying to do is pretty simple. I simply want a list of accounts, but have information like the account owner displayed. I know the ACCOUNT table has "OwnerID", which joins with "ID" in USER, but for some reason I can't get it to link with this SOQL query:

SELECT Id, Name, (SELECT Name from USERS) 
 FROM Account 
 WHERE OwnerId IN 

I get the following error:

SELECT Id, Name, (SELECT Name from USER) 
ERROR at Row:1:Column:36
Didn't understand relationship 'USER' in FROM part of query call. If you are
attempting to use a custom relationship, be sure to append the '__r' after the
custom relationship name. Please reference your WSDL or the describe call for
the appropriate names.

I think you're looking for something like:

select id, name, owner.name from Account where ...

You cannot use a subquery like SELECT Id, Name, (SELECT Name from USERS) because USERS does not match any relationship field on the Account SObject.

| improve this answer | |
  • This works!! obviously I missed an important lesson somewhere.. What just happened? – wizard_draziw Feb 18 '15 at 19:03

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.