You need to sign in to do that
Don't have an account?

Retrieving the name of the owner of an account
Hi everyone;
How can I access (retrieve) the name of the account owner using the name of the account.
I found that account is in look up relationship with User , So running this query results in an error
a) String acctname= [select Owner from account where name=: objAccount.Name];
Error: MyController2 Compile Error: No such column 'Owner' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 16 column 22
b) String acctname= [select a.$User.FirstName from account a where a.name=: objAccount.Name];
Error: MyController2 Compile Error: Didn't understand relationship '$User' in field path. 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. at line 16 column 22
Thanx in advance !!
It is Possible using owner.Name for Account Name like
AccName = 'test';
so SOQL qould be
[select owner.Name from Account Where name = : AccName ];
String acctname= [select Owner.name from account where name=: objAccount.Name limit 1][0].name;